Loading...
Real Time Concepts

How to reset MySQL 5.7 root password on Linux

If you have forgotten your root password, then this post for you here’s how to reset it.

1. Shutdown the MySQL

service mysqld stop

2. Start mysql in safe mode

mysqld_safe –skip-grant-tables

Keep this process running, and don’t close this terminal

3. Open new terminal

4. Login to MySQL as root, and without password

mysql -u root

5. Change to database mysql

use mysql;

6. Now update the password for root user

update user set authentication_string=PASSWORD(‘YOUR-NEW-PASSWORD-HERE’), password_expired = ‘N’ where user=’root’;

notes: In MySQL 5.7, the `password` field was removed, now the field name is `authentication_string`.

7. Don’t forget to flush it

FLUSH PRIVILEGES;

8. Exit

exit;

9. Back to terminal 1, and stop the process (or close it). Then start the MySQL

service mysqld start

10. Now you can login to MySQL with your new password

mysql -u root -pNEW-PASSWORD

Leave a Reply

Your email address will not be published. Required fields are marked *