Notes: Reset Expired root Password for MySQL 5.7 on Mac OS X

I installed MySQL 5.7 from a .dmg package installer for Mac OS X. I followed the installer taking note of the temporary root password given. After the installation, I cannot login as root because the password expired. Here’s what I did.


I stopped MySQL in System Preferences.

MySQL in System Preferences

MySQL in System Preferences


Switched user to root.

$ sudo su


Started MySQL in safe mode.

$ sudo mysqld_safe --skip-grant-tables


I opened another terminal tab/window and lauched mysql shell there.

sh-3.2# mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



Changed root password.

mysql> UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE user='root';
Query OK, 0 rows affected, 1 warning (0.01 sec)
Rows matched: 1  Changed: 0  Warnings: 1



And then,

Query OK, 0 rows affected (0.02 sec)




mysql> \q
sh-3.2# exit



Now try logging in with the new password.

$ mysql -u root -p
Enter password:


It works!

Bookmark the permalink.

Leave a Reply

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