// you’re reading...

Mac OS X

How to restore root to MySQL server on Mac

See my dba.stackexchange.com answer: How to restore root to MySQL server on MAMP

Assuming you went with a generic install of MySQL, my procedure for Mac is:

  1. Edit your my.cnf, probably located at: /usr/local/my.cnf, adding the lines:
skip-grant-tables
skip-networking
  1. Restart mysqld
sudo su -
/usr/local/mysql/bin/mysqladmin shutdown
nohup /usr/local/mysql/bin/mysqld_safe &
exit
  1. Change root privs
mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'password' WITH GRANT OPTION;
  1. Remove the skip lines from the my.cnf
## skip-grant-tables
## skip-networking
  1. Restart mysqld again
sudo su -
/usr/local/mysql/bin/mysqladmin shutdown
nohup /usr/local/mysql/bin/mysqld_safe &
exit

Edited 2015-02-07
*Note: this is not for the “MAMP” packaged install of apache/mysql/php+whatever. This is for Mac .dmg install of MySQL’s distribution of MySQL GA.

Discussion

One comment for “How to restore root to MySQL server on Mac”

  1. this workflow isn’t for mamp. With mamp the path are different. i make a mistake on user root and now i can’t access on database and i’m finding a solution to recover privileges. Can you post the fix for a mamp installation?

    Posted by Luigi | January 9, 2015, 4:37 am

Post a comment

Help support my site and buy a domain name at http://domainsemailhosting.com/

%d bloggers like this: