24

I'm working to set up my MySQL server using MAMP.

Current Status: Downloaded MySQL, MAMP Running MAMP: MySQL Server is green, plus it appears as a process in activity monitor

I tried:

$ mysql
-bash: mysql: command not found

I saw some tutorials that recommended adding a path to my .profile file. So I created a .profile file and added

PATH=$PATH:/Applications/MAMP/Library/bin
export PATH

I then saved it as .profile in the home directory.

Again I tried

$ mysql
-bash mysql: command not found

Does anyone have any idea what's wrong?

Thanks

OS: Mountain Lion

8
  • Do you know where the mysql bin is? Commented Jul 15, 2013 at 21:17
  • have you restarted bash ? as it only reads on start up Commented Jul 15, 2013 at 21:18
  • Is there a mysql binary in /Applications/MAMP/Library/bin? Did you source the .profile or restart the shell? Run echo $PATH Commented Jul 15, 2013 at 21:18
  • echo $PATH ------> /usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/bin:/sbin:/usr/bin:/usr/sbin:/Users/msmith/bin:/opt/local/bin:/usr/local/mysql/bin:/usr/local/mysql/bin Commented Jul 15, 2013 at 21:21
  • The MAMP dir was not in your path, and there seems to be no binary mysql inside it also.. Locate or install mysql client and try running it with an absolute path: /bla/bla/foo/bin/mysql Commented Jul 15, 2013 at 21:28

4 Answers 4

64

A simple way is to just run

sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql

What this does is add a symbolic link for the mysql binary from MAMP into your executable path – in this case, within /usr/local/bin/


Warning: If you’ve installed MySQL manually as well, this may interfere with that installation, so don’t do this if you have!

Sign up to request clarification or add additional context in comments.

1 Comment

Worked great in 2022 for MAMP Pro! Had a PHP script that relied on mysql being available, and now it works perfectly with the MAMP MySQL.
21

This is MAMP for mac.

Firstly check the path where mysql command is located in your machine. For example mine is:

/Applications/MAMP/Library/bin/mysql

Test entering that in terminal will get you some kind of mysql response depending if your login is successful. For e.g:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Now we'll want to add this in $PATH so that you only need to run "mysql" without the folders path.

To do that, first check $PATH, enter in terminal:

echo $PATH

Next enter:

nano .bash_profile

Add this one line (use your own mysql bin path):

export PATH="/Applications/MAMP/Library/bin:$PATH"

Press Ctrl + o to save, press enter/return key to confirm the filename is .bash_profile.

Then Press Ctrl + x to exit the editor.

Close the terminal. Re-open terminal. Enter:

echo $PATH

Your $PATH now includes mysql bin path. You should now be able to call mysql command from any directory.

Credits to http://coolestguidesontheplanet.com/add-shell-path-osx/

Comments

6

MAMP docs (http://documentation.mamp.info/en/mamp/how-tos/using-mysql-command-line) says it should be here:

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

1 Comment

No luck with this solution. still returns No such file or directory
3

First you must verify the path to the mysql binary. After that you can extend (in ~/.profile) your PATH i.e.

export PATH=$PATH:/path/to/mysql/bin/

After editing .profile you have to logout/login to active changes or source your .profile

source ~/.profile

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.