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.
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.
It means either the MySQL server is not installed/running, or the file mysql. sock doesn't exist in /var/lib/mysql/ . There are a couple of solutions for this error. Then try to connect again.
When you got the server running via
mysql.server start
you should see the socket in /tmp/mysql.sock. However, the system seems to expect it in /var/mysql/mysql.sock. To fix this, you have to create a symlink in /var/mysql:
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
This solved it for me. Now my phpMyAdmin works happily with localhost and 127.0.0.1.
Credit goes to Henry
I had some directories left from another mysql(8.0) installation, that were not removed.
I solved this by doing the following:
First uninstall mysql
brew uninstall [email protected]
Delete the folders/files that were not removed
rm -rf /usr/local/var/mysql
rm /usr/local/etc/my.cnf
Reinstall mysql and link it
brew install [email protected]
brew link --force [email protected]
Enable and start the service
brew services start [email protected]
Looks like your mysql server is not started. I usually run the stop command and then start it again:
mysqld stop
mysql.server start
Same error, and this works for me.
Try to connect using "127.0.0.1" instead "localhost".
If you are able to see "mysql stopped" when you run below command;
brew services list
and if you are able to start mysql with below command;
mysql server start
this means; mysql is able to start manually, but it doesn't start automatically when the operating system is started. Adding mysql to services will fix this problem. To do so, you can run below command;
brew services start mysql
After that, you may restart your operating system and try connecting to mysql to see if it started automatically. I did the same and stop receiving below error;
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With