Linux forgot mysql password


If we are handling multiple mysql server we may forget mysql root password.

How to update new root password for mysql:

Just follow these 3 steps to update new password.

  1. Stop mysql daemon.
    • service mysqld stop

      (This command may differ with respect to your operating system).

  2. Now start mysql daemon by skipping the grant tables. Skip grant tables are which will store the passwords of mysql.
    • $ mysqld_safe --skip-grant-tables

  3. Now connect mysql without password
    • $ mysql --user=root mysql

    • Then run following commands in mysql.
      • update user set Password=PASSWORD('new-password') where user='root';
      • flush privileges;
      • exit;

At new-password enter your new password.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s