Mysql command not found in OS X 10.7

Solution 1:

This is the problem with your $PATH:

/usr/local//usr/local/mysql/bin/private/var/mysql/private/var/mysql/bin.

$PATH is where the shell searches for command files. Folders to search in need to be separated with a colon. And so you want /usr/local/mysql/bin/ in your path but instead it searches in /usr/local//usr/local/mysql/bin/private/var/mysql/private/var/mysql/bin, which probably doesn't exist.

Instead you want ${PATH}:/usr/local/mysql/bin.

So do export PATH=${PATH}:/usr/local/mysql/bin.

If you want this to be run every time you open terminal put it in the file .bash_profile, which is run when Terminal opens.

Solution 2:

One alternative way is creating soft link in /usr/local/bin

ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

But if you need other executables like mysqldump, you will need to create soft link for them.

Solution 3:

I faced the same issue, and finally i got a solution. Please go through with the below steps, if you are using MAMP.

  1. Start MAMP or MAMP PRO
  2. Start the server
  3. Open Terminal (Applications -> Utilities)
  4. Type in: (one line) 
 /Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot

This works for me.

Solution 4:

You have to set PATH for mysql in your .bashrc file using following:

  export PATH=$PATH:/usr/local/mysql/bin

But If you are using oh my zsh then you have to add path inside .zshrc file.