How To Use MySQL On MAMP Via Terminal

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’).

 mysql -u root -p

You should now see this:


Here is a very nice post with some more details:
And a list of terminal commands and their meaning:

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:

Now you should get to MySQL simply by typing mysql into the terminal.


Angebot anfordern

Ich melde mich innerhalb von 24 Stunden zurück.