How to reset a MySQL password?
This article describes the steps taken to reset a MySQL user password.
Normal User:
- Login to your MySQL server with the root login: mysql -u root -p
- 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:
- Stop the MySQL server: /etc/init.d/mysql stop or service mysqld stop
- Start the MySQL server without the permission tables: mysqld_safe --skip-grant-tables &
- Login to the server as root, skipping the password prompt: mysql -u root
- 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
- 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.