I’m still quite new to the use of command line, so if there is any better way of doing this, please don’t hesitate to let me know in the comments.
To connect to your MAMP MySQL database via command line, first navigate to the correct directory within your MAMP installation using the Terminal (or another SSH client). Example:
cd /applications/mamp/Library/bin
Then run the command to connect to MySQL (the default user and password are both ‘root’).
Example:
mysql -u root -p
You should now see this:
mysql>
Update:
Here is a very nice post with some more details:
aschroder.com
And a list of terminal commands and their meaning:
ss64.com/osx/
Update:
To avoid typing the location of MySQL each time you open the terminal, you can set the location by default. Open the ‘bash_profile’ file in the user root:
pico .bash_profile
Add the location of MySQL in a new line:
export PATH=$PATH:/Applications/MAMP/Library/bin/mysql
Instructions on how to use the Pico editor here: ss64.com/osx/pico.html
Now you should get to MySQL simply by typing mysql into the terminal.
You forgot dot before “bash_profile”.
It should be “pico .bash_profile”.
And thnx btw
Thanks Pavel, I have updated the post regardingly.
And anyway your avoiding method did’t work for me.
I’ve found another if anyone is interested:
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql
And that’s it. 🙂
Thanks Pavel, your solution worked for me!!