Development

Changing default mysql password for MySQL 5.7 on a Mac

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.

David Carr

David Carr

For the past 12 years, I’ve been developing applications for the web using mostly PHP. I do this for a living and love what I do as every day there is something new and exciting to learn.

In my spare time, the web development community is a big part of my life. Whether managing online programming groups and blogs or attending a conference, I find keeping involved helps me stay up to date. This is also my chance to give back to the community that helped me get started, a place I am proud to be apart of.

Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie, staying in playing games on the sofa or planning a trip to someplace I’ve never been before.