How To Reset MySQL Root Password?

okayrama

Ramashankar

Posted on February 4, 2022

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.

💖 💪 🙅 🚩
okayrama
Ramashankar

Posted on February 4, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

How To Reset MySQL Root Password?
linux How To Reset MySQL Root Password?

February 4, 2022