In case anyone else comes by this issue, the default port on MAMP for mysql is 8889
, but the port that php expects to use for mysql is 3306
. So you need to open MAMP, go to preferences, and change the MAMP mysql port to 3306
, then restart the mysql server. Now the connection should be successful with host=localhost, user=root, pass=root.