Skip to content

Instantly share code, notes, and snippets.

@d4rkd0s
Created October 18, 2018 16:35
Show Gist options
  • Save d4rkd0s/776d3da22336403a312e99c53d66fd82 to your computer and use it in GitHub Desktop.
Save d4rkd0s/776d3da22336403a312e99c53d66fd82 to your computer and use it in GitHub Desktop.
Reset MySQL Password on Mac OS

Stop MySQL service

  • You can do that using the preference pane if you have that installed "Preferences" > "MySQL" (at the bottom)
  • You can stop it using Terminal sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

Skipping Access Tables

  • If you have installed MySQL5, fire up Terminal window and execute /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
  • For older versions of MySQL, execute the following command /usr/local/mysql/bin/safe_mysqld --skip-grant-tables

Reset MySQL root password

Now when safe_mysqld running in one Terminal window open up another Terminal window and execute /usr/local/mysql/bin/mysql mysql

This opening up the MySQL console and opening the mysql table so we can update MySQL root user. Write the reset query into the console as follows

UPDATE user SET Password=PASSWORD(‘YOUR_PASSWORD’) WHERE Host=’localhost’ AND User=’root’;

Replace “YOUR_PASSWORD” with your desired password.

Once you’ve done that just exit the console exit; close the safe_mysqld execution and restart your MySQL server.

You can do this using sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

Once you have done that you can access mysql again with no issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment