Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

w‮l.ww‬autturi.com
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

If you are seeing the error "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)" when trying to connect to MySQL, it means that the MySQL server is not running or the connection to the server is being blocked.

Here are a few possible solutions to this issue:

  1. Check if the MySQL server is running:
systemctl status mysql

If the MySQL server is not running, you can start it using the following command:

systemctl start mysql
  1. Check if the MySQL server is listening on the correct socket:
grep '^socket' /etc/mysql/my.cnf

This will show you the socket that the MySQL server is configured to use. Make sure that this socket matches the one that is specified in the error message.

  1. Check if the MySQL client has the correct socket path:
grep '^socket' /etc/my.cnf

This will show you the socket that the MySQL client is using to connect to the server. Make sure that this socket matches the one that is being used by the MySQL server.

  1. Check if there are any firewall rules that are blocking the connection to the MySQL server:
sudo ufw status

This will show you the current firewall rules on your system. If there are any rules that are blocking the connection to the MySQL server, you can delete or modify the rules as needed.

If you are still having issues after trying these steps, it is possible that there may be other issues with your MySQL configuration or with your system. You may want to check the error logs or seek guidance from the MySQL community for further assistance.

Created Time:2017-10-16 14:38:39  Author:lautturi