I love MAMP for local development on Mac OS X – it gives you a quick LAMP-style development environment on your machine with zero hassle – and it’s free.
If you’re a user who also likes using MySQL on the command line to manage your local databases though, it might be a little confusing, because after installing MAMP you can’t do so. Just run this in terminal and you should be set:
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/
Incidentally, /Applications/MAMP/Library/bin/ is where you’ll also find all the other MySQL binaries, like mysqldump.
Warning: If you’ve installed MySQL manually as well, this may interfere with that installation, so don’t do this if you have!
Blake Lucchesi Said:
Thanks!
ali Said:
i get ’sudo: ln: command not found’
any idea
Chris Dary Said:
ali,
1: note that that is LN, not IN – ‘LN’ lowercase.
2: If you’ve already done that, what version of Mac OS X are you running?
tomo Said:
Thank you, thank you, thank you.
I tried a lot of wrong advices, this one worked like a charm.
julien Said:
Same for me! It works great!
thanks
Gary Said:
I tried this and it says ln: /usr/local/bin/mysql: No such file or directory …… help?
Chris Dary Said:
Gary, did you type this exactly?
’sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql’
Because with that syntax, I don’t know how you could get that error – unless /usr/local/bin didn’t exist, which seems odd to me if you’re on OS X.
If you could paste your entire command I might be able to help more.
Jim Said:
Chris:
I just copied and posted exactly what you wrote into terminal, and got back:
ln: /usr/local/bin/mysql: No such file or directory
I’m on 10.5.6.
Chris D Said:
Hi Jim,
Not sure why the /usr/local/bin directory wouldn’t exist. Try typing this beforehand:
sudo mkdir -p /usr/local/bin
What this will do is create the /usr/local/bin directory for you if it doesn’t already exist.
You might also want to check “echo $PATH” to make sure /usr/local/bin exists within your executable path.
If it doesn’t exist in the string that comes out (separated by colons), just type:
open ~/.profile
and add:
export PATH=$PATH:/usr/local/bin
to that file, and restart your Terminal and you should be all set.
Hope this helps!
Simon Said:
Thanks. That’s a great help.
alex Said:
Before creating the symbolic link that Chris suggested here, I would get “mysql: command not found” unless I entered the whole path such as
/Applications/MAMP/Library/bin/mysql -u root -p
and in that case I would get a blank prompt and nothing would happen.
Now I get the blank prompt if I run any mysql command (including mysql –help), which I suppose is however a kind of progress.
Does anyone know what’s wrong here? There may be a conflict with prior failed installations. I tried to install mysql previously with macports, but I uninstalled it later. I have a ruby on rails stack installed as well, but there’s no mysql support there. I’ve just been using Sqlite3. I don’t know if there could be a potential conflict with another mysql installation or not. How can I check? Or is there another solution that occurs to anyone?
I know that mysql is running–I can use phpmyadmin and query databases with php–but I’d really like to be able to use the command line! Any help is much appreciated!
Anono mouse Said:
Hey Jim,
Try This:
/usr/local/mysql/bin/mysql
tomo Said:
Thanks!
Stefan Said:
Hey there!
I’ve done as you said, but i get the following massage:
110:~ appleuser$ sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type “man sudo” for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
ln: /usr/local/bin/mysql: No such file or directory
110:~ appleuser$
Any idea what it could be?
I run MySQL and MAMP on a MacBook Pro with OS 10.5.6.
Stefan Said:
Ohhh, sorry! I just read the other comments up there and found the solution. Thanks a lot to all of you! That was a great help!!!
Ian Hoar Said:
Thanks, this worked great with one modification. I think the bin directory is not in the same spot on all OSX installations as a lot of people seem to be having issues. I went and manually looked for it and saw it was /usr/bin/ and not /usr/local/bin. Modified command below worked perfect for me.
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/bin/mysql
Thanks for pointing me in the right direction.
betz Said:
indeed, same here
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/bin/mysql
Chris Dary Said:
Ian/Betz:
I’m willing to bet the problem was that /usr/local/bin was not in your PATH.
If you do “echo $PATH | grep /usr/local/bin” does anything show up? If not, you need to add /usr/local/bin to your PATH, which you can do by typing:
echo ‘export PATH=$PATH:/usr/local/bin’ >> ~/.profile
Putting the link into /usr/bin works as well of course, but /usr/local/bin is usually reserved for user-written tweaks and scripts.
rafaelxy Said:
guys, some recent Mac OS X versions, mine 10.6, doesnt have /usr/local/bin but it does have /opt/local/bin
just echo $PATH and check it out. Im guessing apple changed that for some reason
Saïd Said:
Thanks !!!!!
you save me from be lost in my exercise !!!
thanks again….
Pepitoto Said:
I tried both “/usr/bin/mysql” & “/usr/local/bin/mysql” and in all cases it returns
“WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type “man sudo” for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:”
After entering password it comes back to “iMac-Thomas:~ thomas$ ”
what should I do?
gmnote Said:
Thanks, very useful. Also using Sequel Pro (http://www.sequelpro.com/) if you like GUI based stuff
Sasha Dzeletovic Said:
Thanks a lot Chris! I was importing a large sql file into MAMP MySQL and wanted to avoid phpMyAdmin size limitation by going straight to command line to do the import. Worked like a charm.
bauer Said:
Really thanks man, I was looking for this because my “mysqldump” command didn’t work and this solution is perfect for me.