Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql command is not found after installing using homebrew

Tags:

mysql

homebrew

I uninstalled newest mysql and tried to install mysql 5.7 on Mac by downloading from offical website, however it said the previous version is still installed on my Mac. I tried all methods I found, and they didn't work. I also couldn't found any mysql files on my Mac. So I installed mysql using home brew. And the path is {/usr/local/Cellar/[email protected]/5.7.29}. I followed some method and opened bash_profilescreenshot

I changed path to {/usr/local/Cellar/[email protected]/5.7.29/bin}, and I still got a command not found. I once also get mysql running by using {brew services start [email protected]}, but when I type {mysql -u root -p} it showed: " /usr/local/mysql/bin/mysql: No such file or directory".

Really appreciate it if anyone know what's the problem here.

like image 342
joiningcode Avatar asked Feb 17 '20 12:02

joiningcode


People also ask

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.

How do I start MySQL on Mac?

Open macOS system preferences and select the MySQL preference panel, and then execute Start MySQL Server. The Instances page includes an option to start or stop MySQL, and Initialize Database recreates the data/ directory.


2 Answers

i had this problem too. looks like the installer isn't creating the symlink for some reason. this should fix it.

cd /usr/local/bin
ln -s ../Cellar/[email protected]/5.7.29/bin/mysql mysql
like image 123
Anthony Townsend Avatar answered Oct 23 '22 17:10

Anthony Townsend


As Homebrew says

[email protected] is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH, run:

  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

Reload zsh config after installed.

source ~/.zshrc

Or open a new terminal.

like image 1
xofred Avatar answered Oct 23 '22 18:10

xofred