MySQL MySQL守护进程锁问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34954455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:33:38  来源:igfitidea点击:

MySQL Daemon Lock issue

mysqlsocketsdebian

提问by SamboyCoding

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 -pcommand, I get:

昨晚,我的 MySQL 服务器意外宕机。在尝试重新启动(使用service mysql restart- 我是 root)时,它只是挂起。使用mysql -u root -p命令,我得到:

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

错误 2002 (HY000):无法通过套接字 '/var/run/mysqld/mysqld.sock' (2) 连接到本地 MySQL 服务器。

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:

然后我尝试手动启动守护程序 ( mysqld)。提示将挂起约 2 秒钟,然后返回。在仔细检查错误日志后,我得到:

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.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.399622Z 0 [ERROR] Unable to setup unix socket lock file.

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

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

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

然后我试了一下chown mysql /var/run/mysqldchmod -R 775 /var/run/mysqld然后apt-get install mysql-community-server --reinstall。没运气。

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

注意:我正在使用 MySQL 社区服务器 5.7.10 运行 Debian 8 (Jessie)

采纳答案by SamboyCoding

Fixed. Add skip-external-lockingto my.cnfunder the [mysqld]section, and then reboot the entire system. This should fix it, for anyone who finds this. Also if you backed up your data, then attempted to restore and were told to rm ib*to make it work, you need the ibdatafile.

固定的。添加skip-external-lockingmy.cnf[mysqld]部分下,然后重新启动整个系统。对于任何发现此问题的人,这应该可以解决它。此外,如果您备份了数据,然后尝试恢复并被告知rm ib*要使其工作,则您需要该ibdata文件。

回答by jorfus

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

我刚遇到这个。mysql 安装有点奇怪,缺少 /var/run/mysqld/

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

MySQLd 试图创建套接字和锁定文件,但缺少父目录。我只是创建了目录

sudo mkdir /var/run/mysqld

chowned it to mysql

chown 到 mysql

sudo chown mysql:mysql /var/run/mysqld

I was then able to start mysqld normally.

然后我就可以正常启动mysqld了。

回答by affitz

I experienced the same issue today on my Ubuntu server. But I think the solution is NOT to disable locking. In my case, a look at the system log (dmesg | tailand journalctl -xe) revealed that it's an apparmor issue and the solution can be found in this question.

我今天在我的 Ubuntu 服务器上遇到了同样的问题。但我认为解决方案不是禁用锁定。在我的情况下,查看系统日志(dmesg | tailjournalctl -xe)表明这是一个 apparmor 问题,可以在这个问题中找到解决方案。

回答by David Raleche

I had following error

我有以下错误

[ERROR] Unix socket lock file is empty /var/lib/mysql/mysql.sock.lock.
[ERROR] Unix socket lock file is empty /var/lib/mysql/mysql.sock.lock.

This error came up as a result that my server was lacking space 100% use (see below)

出现此错误的原因是我的服务器空间不足 100% 使用(见下文)

Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/xvda1      41153856 28531384  12187364  100% /

Make sure the folder exists with the proper permissions

确保该文件夹以适当的权限存在

chown mysql:mysql /var/lib/mysql/

And make sure to delete the file so the mysql server could generate a new one

并确保删除该文件,以便 mysql 服务器可以生成一个新的

rm /var/lib/mysql/mysql.sock.lock

回答by Navaneeth Pk

If you are using docker to run MySQL, please check if there is enough allocated disk space in docker preferences.

如果您使用 docker 运行 MySQL,请检查 docker 首选项中是否有足够的分配磁盘空间。

回答by 4n70wa

Also may be out of disk space.

也可能是磁盘空间不足。

回答by Prasath Rajan

Below commands worked for me.

以下命令对我有用。

sudo mkdir /var/run/mysqld

sudo chmod 777 /var/run/mysqld -R

回答by Vikas Patel

Rename /var/lib/mysql/mysql.sock.lock & /var/lib/mysql/mysql.sock to /var/lib/mysql/mysql.sock.lock.bck & /var/lib/mysql/mysql.sock.bck respectively and start mysqld. It works

将 /var/lib/mysql/mysql.sock.lock & /var/lib/mysql/mysql.sock 重命名为 /var/lib/mysql/mysql.sock.lock.bck & /var/lib/mysql/mysql.sock .bck 分别启动 mysqld。有用