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

x


Angebot anfordern

Ich melde mich innerhalb von 24 Stunden zurück.