Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql command not found in OS X 10.7

Tags:

mysql

People also ask

Why is MySQL command not found Mac?

On macOS, you should be able to use mysql command once you installed MySQL using the official macOS installer or Homebrew. If you find the command not found error, then you need to manually add the bin/ folder to your . bashrc or . zshrc file if you use ZSH command line client.

Why MySQL command is not working?

Causes of the 'Command Not Found' Error The 'Command Not Found' error indicates that your system was not able to locate the program you want to run. Two of the most common reasons for this error are: 1. Corrupt MySQL installation: In some instances, the MySQL installation process might be corrupted.


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.


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.


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.


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.