Search code examples
mysqlmamphomebrew

How to make MySQL command line works with MAMP?


I love the conveniences of MAMP e.g. phpMyAdmin so I installed it.

I also installed MySQL via Home Brew because I need MySQL command line (mainly for import and export).

Now entering mysql results in:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

What should I do?


Solution

  • The MAMP mysql socket is located elsewhere. If you installed MAMP and own mysql parallel, you have two instances. One with MAMP context, which has its binary in

    /Applications/MAMP/Library/bin/
    

    Other one depending on your settings during install.

    Make sure to start mysql (the one you would like to work with). You might want to use command line as follows:

    /Applications/MAMP/Library/bin/mysql [command goes here]
    

    To access the MAMP mysql server.