RESET MYSQL ROOT PASSWORD OSX

Reset MySQL root Password in OSX 10.10 +

Doh!  Forgot the MySQL root password for the local MAc OS 10.x !

Let me say first, check your project config files to see if you can find it (duh).  If that does not work, or if you just plain want to reset the local root password for mysql on your Mac (OS 10.x), then try the following.

How to reset the local root password for your Mac OS system using the command line terminal of your Mac.

First, in the mac terminal, stop the MySQL service like this:

pauL ⨊ $> sudo sudo mysql.server stop
Password: *********
Shutting down MySQL
.. SUCCESS! 

Then start it but skipping the grant tables:

pauL ⨊ $> sudo sudo mysql.server start --skip-grant-tables
Starting MySQL
. SUCCESS!

Now open another terminal.

In the new terminal you should be able to log in with no password:

pauL ⨊ $> mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 Homebrew

Copyright (c) 2000, 2015, 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
owners.

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

mysql>

Now edit the mysql.user table with the following script and then flush the privileges.

mysql> UPDATE mysql.user SET authentication_string=PASSWORD('4pivp/veCos[wt/2]') WHERE User='root';  
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql>FLUSH PRIVILEGES; 
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

if you are using MySQL prior to 5.7, then you need to replace the string ‘authentication_string’ with ‘Password’. The new Script will look like this:
like this:.

mysql> UPDATE mysql.user SET Password=PASSWORD('my-new-password') WHERE User='root';
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql>FLUSH PRIVILEGES; 
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

With that part done, go back to the other terminal and stop the server:

pauL ⨊ $ sudo mysql.server stop
Password:*********
Shutting down MySQL
.. SUCCESS!

Then restart the server:

pauL ⨊ $ sudo mysql.server start
Starting MySQL
. SUCCESS!

And now you should be able to log back into you local root mysql account on you Mac!

pauL ⨊ $ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 Homebrew

Copyright (c) 2000, 2015, 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
owners.

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

mysql>

YAY! I hope that helped. : )

One thought on “RESET MYSQL ROOT PASSWORD OSX

Leave a Reply

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