How to change MySQL’s root password on Mac OS X

First off all, you have to stop MySQL. You can do this by either killing mysql related processes or by stopping the service – it depends on how you start mysqld.

1. Stop service by executing

/sbin/SystemStarter stop "MySQL"

2. After server is stopped, start it “manually” following way:

/usr/local/mysql/bin/mysqld --skip-grant-tables --user=root

3. Start mysql client:

/usr/local/mysql/bin/mysql -u root

4. Execute queries:

update mysql.user set Password=PASSWORD('password') where User='root';
flush privileges;

5. Kill mysqld and starting the service again:

kill -9 `ps -o pid,command -ax | grep mysqld | grep -v "grep" | cut -f1 -d" "`

6. Start MySQL service again

/sbin/SystemStarter start "MySQL"

7. Login as root:

/usr/local/mysql/bin/mysql -u root -p

Comments (2)

anonymousApril 10th, 2014 at 7:55 pm

AMAZING thanks so much.

anonymousMay 19th, 2014 at 5:55 am

Thanks! It’s very helpfull.