2014-11-03 OS X
After MAMP is installed on OS X, you can use command line (terminal) to access MySQL in exactly the same way as on Linux. It’s very handy when you have to deal with importing or exporting huge SQL files. On of the things that can become little bit frustrating is that when normally you would like to access MySQL, you would type
mysql -u root -p
In OS X you have to provide full path to MySQL. Since the path is long (see below), it’s not a convenient way. To achieve the same as above you have to type
/Applications/MAMP/Library/bin/mysql -u root -p
In this article I will show you, how can we create an alias and access MySQL much faster.
Open terminal and go to you home directory
Now create a new file called
Open this file
When an edit window will appear, type the following line (I assume that you didn’t change the default path where MAMP is installed. If you did, change it to a proper location).
alias mysql='/Applications/MAMP/Library/bin/mysql -u root -p'
Save the file by pressing
Quit the window by pressing
We’re not done yet. Last step – force the change you’ve done to take effect. Since .bash_profile is executed every time you log in, we have to reload the content without rebooting.
Now you should be able to use mysql alias. Try it! After typing
you should be asked for root’s password. If you didn’t change it, it’s root, otherwise it’s the one you set after installing MAMP.