Retrieve or Reset the Root MySQL Password
MySQL AB was a software company that was founded in 1995. It was acquired by Sun Microsystems in 2008; Sun was in turn acquired by Oracle Corporation in 2010.
This is a quick tutorial how to reset your MySQL root password. It does require root access on your server.
Step #1
Stop MySQL:
service mysql stop
Step #2
Start MySQL in single-user mode, bypassing password authorization, by pasting in the command below (the ampersand is required):
mysqld_safe --skip-grant-tables &
Step #3
Now type "mysql" to connect:
mysql
Step #4
At the mysql prompt, change the root password using the following three commands:
UPDATE mysql.user SET password=password("YourNewStrongPassword") WHERE user='root';
FLUSH PRIVILEGES;
exit;
Step #4
Now stop MySQL and start it in normal mode:
service mysql stop
service mysql start
Step #5
Verify that you are able to connect to MySQL by entering "mysql".
Step #6
Finally, update the MySQL root password in /etc/.my.cnf to match the new value. You can use vi, vim or nano:
vi /root/.my.cnf
Recovering the Root MySQL Password on a cPanel server
The root MySQL credentials are stored locally in a file that only the root user can access. After you’ve connected to the server as root via SSH, you can view the credentials by running the following command:
cat /root/.my.cnf
That should output a result containing the MySQL password, which will appear similar to the following:
[root@host ~]# cat /root/.my.cnf
[client]
password=#@hackthesec
user=root
www.hackthesec.co.in
https://www.twitter.com/Hackthesecurity
http://facebook.com/htsecu
http://feeds.hackthesec.co.in/hackthesec
0 comments:
Post a Comment