DEV Community

Ramashankar
Ramashankar

Posted on • Edited on

How To Reset MySQL Root Password?

Everyone is their life have forgotten tons of password and I'm one of those too. However, resetting the password isn't a hard task at all. This article will teach you to reset the MySQL Root Password with ease. You can learn about it in detail here on TheDroidGenome.

Pre-requisites

You must have root access to your server before you can start resetting it. You can obtain it easily with the help of sudo command.

Reset MySQL Password

  • First things first, stop the MySQL Server.
    sudo service mysql stop

  • Once the server is stopped, restart it the —skip-grant-tables option
    mysql_safe --skip-grant-tables &

  • Connect to MySQL by the following command
    mysql -uroot

  • Setup new password using following command
    UPDATE mysql.user SET Password=PASSWORD('updated-password') WHERE User='root';

  • Now, Restart you server to take it in effect.
    sudo service mysql restart

Wrapping Up

That's how you can reset your MySQL password easily. Let me know if you get any errors or queries. I will be more than happy to help you out.

Top comments (0)