Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brew services list shows mysql running but cannot connect

Tags:

mysql

homebrew

I followed instructions on installing mysql using brew from here https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e

brew services list shows below output

Name  Status  User         Plist
mysql started <username> /Users/<username>/Library/LaunchAgents/homebrew.mxcl.mysql.plist

But when I run 'mysql' or 'mysqladmin -u root password '' I get error.

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

Can anybody tell the issue here.

like image 683
user27111987 Avatar asked Jul 25 '18 06:07

user27111987


People also ask

Can't connect to local MySQL server?

normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.

Can't connect to local server through socket '/ tmp MySQL sock brew?

To fix this error, you need to see if MySQL server is already installed and running on your computer. That should start the server and generate the mysql. sock file. You can try to connect to your MySQL server again now.

How fix MySQL is not starting?

Try manually start the service from Windows services, Start -> cmd.exe -> services. msc. Also try to configure the MySQL server to run on another port and try starting it again. Change the my.


1 Answers

What is your MySQL version? Recently MySQL v8 was released and it is causing problems.

I suggest to first stop the MySQL service via brew services stop mysql and then uninstall MySQL via brew uninstall mysql.

Next, please remove its data folder by executing rm -rf /usr/local/var/mysql.

After that please do brew upgrade.

If you want to install MySQL v5.7 just do

brew install [email protected] && brew link --force [email protected] && brew services start [email protected]

This also works for [email protected] and [email protected].

like image 162
Damian Dziaduch Avatar answered Oct 19 '22 02:10

Damian Dziaduch