Sorry to hear you’re having trouble with the instructions in my book!
If you have shut down and restarted MAMP, that’s going to do the same as the flush-privileges command, so I wouldn’t worry about that.
Given that you can only connect with the password 'mypassword' from the Terminal, and only connect with the password 'root' from PHP, it’s sounding a lot like you have more than one MySQL server running on your system. Can you try this experiment for me?
- Quit the MAMP application.
- Open Terminal.
- Try to connect to MySQL (using the 'mypassword' password that usually works there).
If you are able to connect to MySQL, you’ll know for sure that what you’re talking to from the Terminal isn’t the MySQL server built into MAMP, but another copy of MySQL that you have installed on your computer by some other means.
Let me know what you discover, and we’ll take it from there.