简体   繁体   中英

Installed mysql@5.6 using brew mysql.server not a command

I installed mysql@5.6 using brew. Below are the comands I ran

brew install mysql@5.6

sudo chmod -R 777 /usr/local/var/mysql

sudo ln -s /usr/local/Cellar/mysql\@5.6/5.6.41/bin/mysql /usr/local/bin/mysql

sudo cp /usr/local/Cellar/mysql\@5.6/5.6.41/homebrew.mxcl.mysql.plist /Library/LaunchAgents/

sudo chown root /Library/LaunchAgents/homebrew.mxcl.mysql.plist

sudo chmod 600 /Library/LaunchAgents/homebrew.mxcl.mysql.plist

sudo chmod +x /Library/LaunchAgents/homebrew.mxcl.mysql.plist

launchctl load -w /Library/LaunchAgents/homebrew.mxcl.mysql.plist

mysql.server start

sh: mysql.server: command not found

this is the output I am getting. mysql --version is giving output

mysql Ver 14.14 Distrib 5.6.41, for osx10.13 (x86_64) using EditLine wrapper

If I start service via brew its starting

brew services start mysql@5.6

But when I run mysql -uroot I am getting

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I think you need to start the service as well:

brew services start mysql@5.6

You can then check so the mysql service is running using:

brew services list

Now try to create symlinks for the mysql package:

brew link --force mysql@5.6

You might need to add the location to mysql to your path, to find the location of the package:

brew list mysql@5.6

Then add the location to the bin folder to the end of your ~/.profile or ~/.bash_profile file. For instance:

export PATH=$PATH:/usr/local/Cellar/mysql@5.6/5.6.41/bin

Then reload the file:

source ~/.bash_profile

Now you should be able to use the mysql and connect to the local running server.

$ vi ~/.bash_profile

write

PATH=${PATH}:/usr/local/mysql/bin

PATH=${PATH}:/usr/local/mysql/support-files

in it. save it.

$ source ~/.bash_profile and then try mysql.server start

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM