Reset expired root MySQL password

MySQL – “Your password has expired. To log in you must change it using a client that supports expired passwords”

What a hugely frustrating problem, to one day try to connect to your local MySQL instance only to find the password expired. I guess if it wasn’t my local instance it may not be such a bad thing from a security perspective but anyway…

After trying a number of things this one worked for me on Windows 7, MySQL version 5.7.

(1) Shutdown the MySQL service instance (Windows -> Run then type services.msc, right-click MySQL57 and stop)

(2) Open the  “MySQL 5.7 Command Line Client” (Windows -> Run then type MySQL, it will appear in the list)

(3) You will be prompted for a password, enter the old root password.

(4) In the MySQL console:

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> SET PASSWORD FOR root@’localhost’ = PASSWORD(‘root1’);
Query OK, 0 rows affected, 1 warning (0.00 sec)

(5) Restart the MySQL service and that should be that.