To use the MySQL command line with MAMP or MAMP PRO, perform the following steps:- Start MAMP or MAMP PRO
- Start the server
- Open Terminal (Applications -> Utilities)
Type in: (one line)
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

Do you have to do this all the time? As in each terminal session you have to type in that line to use mysql in command line? What is the stuff I need to add to my .profile to access mysql directly without having to put that pathname in all the time?
ReplyDeleteI created symbolic links like so. Now all I have to do is type mysql to connect to the server.
ReplyDeletesudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql
You can also set this up for mysqldump etc..
Another easy way to do it is add the following lines to your .profile file in your home directory:
ReplyDeleteexport PATH=$PATH:/Applications/MAMP/Library/bin
then type ". .profile" (without the quotes) to reload your profile
Then type: echo $PATH
and make sure that line is in there. Then you have access to everything in the bin directory so you can use the mysqladmin tool if you need to.
Thank for MySQL command tutorial. I will use it.
ReplyDeleteThank you as an old user of Linux to a new user of mac this was a nice nudge in the right direction.
ReplyDeletethanks for this!
ReplyDeleteI get this error:
ReplyDeleteERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
Even this didn't help:
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
It worked thanks!
DeleteI just had to restart the MySQL server.
Thanks