Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Daemon Lock issue

Last night, my MySQL server went down unexpectedly. On attempting to restart (with service mysql restart - I'm root) it merely hangs. With the mysql -u root -p command, I get:

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

I then tried to start the daemon manually (mysqld). The prompt would hang for about 2 seconds, and then return. On closer inspection of the error logs, I got:

2016-01-22T19:18:32.399584Z 0 [ERROR] Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock.

2016-01-22T19:18:32.399622Z 0 [ERROR] Unable to setup unix socket lock file.

2016-01-22T19:18:32.399646Z 0 [ERROR] Aborting

I then tried chown mysql /var/run/mysqld, chmod -R 775 /var/run/mysqld and apt-get install mysql-community-server --reinstall. No luck.

I have looked around, and couldn't find a solution. Any help here?

Note: I am Running Debian 8 (Jessie) with MySQL community Server 5.7.10

like image 255
SamboyCoding Avatar asked Jan 22 '16 19:01

SamboyCoding


People also ask

What is daemon in MySQL?

The main MySQL server program, or MySQL server daemon, is called mysqld . Under Windows, there are two main programs you can use: mysqld-nt.exe—which is optimized for Windows XP, 2000, and NT (and probably soon, for Vista)—and mysqld.exe, which can work on older versions of Windows.

Does MySQL select lock the table?

MySQL uses table locking (instead of row locking or column locking) on all table types, except InnoDB and BDB tables, to achieve a very high lock speed.

What is read lock in MySQL?

READ LOCK: This lock allows a user to only read the data from a table. WRITE LOCK: This lock allows a user to do both reading and writing into a table. It is to note that the default storage engine used in MySQL is InnoDB.


1 Answers

I just ran into this. The mysql install was a little weird and was missing /var/run/mysqld/

MySQLd was attempting to create the socket and lock file but the parent directory was missing. I simply created the directory

sudo mkdir /var/run/mysqld 

chowned it to mysql

sudo chown mysql:mysql /var/run/mysqld 

I was then able to start mysqld normally.

like image 98
jorfus Avatar answered Sep 23 '22 00:09

jorfus