Loading...
 

How to reset a MySQL password?


This article describes the steps taken to reset a MySQL user password.

Normal User:

  1. Login to your MySQL server with the root login: mysql -u root -p
  2. Execute these commands, replacing with your desired password and user:

    mysql> use mysql;
    mysql> update user set password=PASSWORD("NEWPASSWORD") where User='username';
    mysql> flush privileges;
    mysql> quit

Root User:

  1. Stop the MySQL server: /etc/init.d/mysql stop or service mysqld stop
  2. Start the MySQL server without the permission tables: mysqld_safe --skip-grant-tables &
  3. Login to the server as root, skipping the password prompt: mysql -u root
  4. Execute the following commands to change the root password:

    mysql> use mysql;
    mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
    mysql> flush privileges;
    mysql> quit

  5. Restart the MySQL server: /etc/init.d/mysql restart or service mysqld restart

You now should be able to login with the new root password as normal.