Mysql command in terminal with mamp

For those who are having problem with mysql command in terminal,

if you are getting an error message when you type mysql in command after you installed MAMP on mac,

Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

The solution is easy,

go to your terminal,

sudo nano /etc/my.cnf

and paste in this line..

[client]
socket=/Applications/MAMP/tmp/mysql/mysql.sock

click command O to save the file and command X to exit, restart your MAMP and there you go!