Introduction
MySQL manages connections to the database server through socket file.
This file helps in communications between different processes in MySQL. This file is called mysqld.sock.
In the Linux systems it’s stored in /var/run/mysqld/
directory.
If you face a socket error, the foremost solution is to restart
$ sudo systemctl start mysql ... $ sudo systemctl restart mysql
Let us frsst verify where is the instllation of MySQL is done
$ sudo nano /etc/mysql/mysql.conf.d/mysql.cnf
Output should be like this /etc/mysql/mysql.conf.d/mysqld.cnf
. . . [mysqld] user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 . . .
Now let us check the socket file
$ ls -a /var/run/mysqld/
If the file does not exist, let us first check the permissions
$ sudo chown mysql:mysql /var/run/mysqld/ ... $ sudo chmod -R 755 /var/run/mysqld/
Now restart MySQL after changing the MOD permission
$ sudo systemctl restart mysql
The problem should be resolved now . If the problem still persist .
Please note MySQL documentation include other preventive way of diagnosing crashes.
Download from the link below.
MySQL What to Do If MySQL Keeps Crashing