Last Updated: February 25, 2016
·
4.994K
· kungfucarlos

Resetting your MySQL root password on Mac OSX Lion

Create a mysql-init file in your home directory containing:

UPDATE mysql.user SET Password=PASSWORD('{newrootpassword}') WHERE User='root';
FLUSH PRIVILEGES;

Stop MySQL

sudo launchctl unload -w /Library/LaunchDaemons/org.mysql.mysqld.plist

Run MySQL manually

mysqldsafe -user=mysql --init-file={homedirectorypath}/mysql-init &

Check you can login to MySQL using new password
mysql -u root -p
password: {newrootpassword}

Delete your mysql-init file

Kill your manually created MySQL process

Relaunch MySQL

sudo launchctl load -w /Library/LaunchDaemons/org.mysql.mysqld.plist