Knowledge Base
MilesWeb / How-Tos

How To Recover MySQL Root Password?

Approx. read time : 2 min

You can recover MySQL root password if you don’t remember the old password OR if it isn’t working. Performing 5 steps with the commands as it is, will reset the MySQL root password for you.

1. Stop the MySQL service.
2. Start the MySQL service in safe mode. Doing this, it won’t ask you for password.
3. Access MySQL as root user.
4. Set a new password for MySQL root user.
5. Restart MySQL service.

Above are the steps. If you are unsure with the commands, kindly follow them as below.

1. Stop the MySQL service.
# /etc/init.d/mysql stop

2. Start the MySQL service in safe mode. Doing this, it won’t ask you for password.
# mysqld_safe –skip-grant-tables &

3. Access MySQL as root user.
# mysql -u root

4. Set a new password for MySQL root user.
mysql> use mysql;
mysql> update user set password=PASSWORD(“New-Password”) where User=’root’;
mysql> flush privileges;
mysql> quit

5. Restart MySQL service.
# /etc/init.d/mysql stop

Now try connecting MySQL with the new root password. You should be able to get into the MySQL prompt.

Note: Replace New-Password in Step 4 with the actual password you wish to set.

Admin
With over 10+ years of experience in the web hosting industry, I have achieved extensive exposure to result-oriented methodologies. And expertise in different domains like Datacentre Services, Cloud computing technology, Web hosting industry and many more.