Resetting Root Password in MAMP

I struggled for a while to do this as I expected MAMP to automatically update the root password after I’d changed it in the mysql.user table. To be clear, it does not. And so, here’s a brief guide to sorting out you MAMP woes.

First, connect to mysql using Terminal. MAMP is automatically set to use root as the user account to connect to mysql. Funnily enough, root is also the password!

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
You’ll be logged into mysql and will see the following.
Last login: Wed Dec 28 14:48:04 on ttys001
ZoooJs-MacBook-Pro:~ zoooj$ /Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 38
Server version: 5.1.44 Source distribution

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
 The next thing to do is reset your password. Type the following replacing your-new-password with your new password. You should see the Query OK message.
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your-new-password');
Query OK, 0 rows affected (0.00 sec)
Once that’s done you need to edit a number of files in the /Applications/MAMP/ directory. I still can’t quite believe that you have to do this in so many places. You’d think they would have a single file that has the master password set. Hey ho, maybe not.
So, find and edit these files using a plain text editor, not TextEdit, Word, OpenOffice, etc. Use TextWrangler or another decent Mac IDE. TextWrangler is free. You’ll need to find the line that has -proot and change it to read -pyour-new-password. Note that there is no space between -p (stands for password) and the password itself.

/Applications/MAMP/bin/phpMyAdmin/config.inc.php
/Applications/MAMP/bin/checkMysql.sh
/Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
/Applications/MAMP/bin/repairMysql.sh
/Applications/MAMP/bin/stopMysql.sh
/Applications/MAMP/bin/upgradeMysql.sh
/Applications/MAMP/bin/MAMP/index.php

Restart MAMP and all should be well.