mysql command doesn’t work in OS X snow leopard
So you install mySql on your mac, and it’s working great, but then you go into terminal to run a mysqldump or something, and it doesn’t work!
you get a message something like:
-bash: mysqldump: command not found
so how do you fix this? well, copy and paste the following into your terminal window and press enter:
echo export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" >> ~/.profile
source ~/.profile
whoa, whoa, you say. what is this doing? It makes it so that when you type any command into the terminal, it does a check of these folders before giving you the “command not found” error.
If you want to undo it, you can always edit your .profile, or just delete it.
April 11th, 2010 at 2:13 am
Hello J.
I tried your solution but did’nt work for me.
I still get the “command not found” message and a 0bytes file is created.
I opened a tread in the Mysql Forum http://forums.mysql.com/read.php?10,362651,362651#msg-362651
Maybe you can help me…?
Thanks,
Matt
April 11th, 2010 at 9:26 am
Matt, depending on which version of mySQL you have installed, it might not be in the same folder. it depends whether you’ve installed it with the installer or compiled it yourself.
Navigatie to /usr/local/mysql/bin in terminal. if it’s not there, you know that’s the problem. if it is there, type ./mysqldump and you can run it that way. If you’re unable to find it there, I’d look up different locations for mysql and change the path accordingly in the command above.
hope that helps.
April 11th, 2010 at 11:53 am
Thanks J.
The only mysqldump file I have on my computer is in : /Applications/MAMP/Library/bin/mysqldump
But the following command still doesn’t work:
iMac-de-Matthieu-Neale:bin matthieuneale$ mysqldump -a -u -p soukha_be > base_test.mysql
-bash: mysqldump: command not found
What am I doing wrong?
April 11th, 2010 at 11:55 am
Matt – mysql is only installed as part of MAMP, you don’t have it on your computer itself. because of this, the mysql daemon is only running when MAMP is running. if you launch MAMP then navigate in terminal to /Applications/MAMP/Library/bin/ then type ./mysqldump -a -u -p soukha_be > base_test.mysql you may have better luck :)
April 11th, 2010 at 12:14 pm
You’re the man!!!!!
Thanks a lot, it’s working smooth now!
Matt