Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  How-Tos  >  How to Recover MySQL Root Password ?
Top Scroll

How to Recover MySQL Root Password ?

 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.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.