Notes

Connect to MySQL installed by MAMP via Command Line (Terminal)

Edit on GitHub

Databases

tl;dr: You have to mention the socket file. The socket file is usually at

/Applications/MAMP/tmp/mysql/mysql.sock

Provide that socket file location in the command

1# Connect to MySQL
2mysql -uroot -proot --socket=/Applications/MAMP/tmp/mysql/mysql.sock
1# Backup all databases
2mysqldump -uroot -proot --socket=/Applications/MAMP/tmp/mysql/mysql.sock --all-databases > all_databases.sql

You can confirm the connection details on MAMP’s WebStart page: http://localhost:8080/MAMP/?language=English