I cant get my mysql to start on os x 10.7. It is located in /usr/local/mysql/bin/mysql
I get command not found when I type mysql --version
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.
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.
If you installed MySQL Server and you still get
mysql -u root -p command not found
You're most likely experiencing this because you have an older mac version.
Try this:
in the home directory in terminal open -t .bash_profile
paste export PATH=${PATH}:/usr/local/mysql/bin/
inside and save it
instead of writing mysql -uroot -p
paste the following in your terminal:
/usr/local/mysql/bin/mysql -uroot -p
Enter your password. Now you're in.
Maybe I'll help someone else. None of the above answers worked for Catalina. Finally, this solved the problem
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> /Users/$(whoami)/.bash_profile
Of course, you have to change for the version of mysql you have installed
If you are using terminal you will want to add the following to ./bash_profile
export PATH="/usr/local/mysql/bin:$PATH"
If you are using zsh, you will want to add the above line to your ~/.zshrc
Your PATH might not setup. Go to terminal and type:
echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile
Essentially, this allows you to access mysql from anywhere.
Type cat .bash_profile
to check the PATH has been setup.
Check mysql version now: mysql --version
If this still doesn't work, close the terminal and reopen. Check the version now, it should work. Good luck!