MySQL said: Can’t connect to MySQL server on ‘127.0.0.1’ Mac OS

 

can’t connect to local mysql server through socket ‘/tmp/mysql.sock’

Cách này có chỉ trên mạng, nhưng nếu bí quá thì gỡ là cách sạch nhất có thể.

Gỡ mysql:

brew uninstall mysql@5.7

brew uninstall –force mysq

brew remove mysql
brew cleanup

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySql*

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

 

Cài mysql:

brew install mysql@5.7

brew services start mysql@5.7