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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With