Changing default mysql password for MySQL 5.7 on a Mac

David Carr

Development

Today’s I’ve reinstalled my os and decided to install mysql in terminal I didn’t make a note of the temp password, so when I tried to run mysql I get access denied. The password needed changing these are the steps I followed.

Turn off mysql from system preferences – MySQL

In terminal type: 

sudo mysqld_safe --skip-grant-tables

This starts safe mode then enter as root:

mysql -u root

Change the password for root: in my case I’ve using root as the password.

UPDATE mysql.user SET authentication_string=PASSWORD('root') WHERE User='root';

the output should read:

Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

then exit safe mode by typing:

exit;

Now you should be able to login to mysql using the username and password of root.

Copyright © 2006 - 2024 DC Blog - All rights reserved.