问题描述
昨晚,我的 MySQL 服务器意外宕机.在尝试重新启动时(使用 service mysql restart
- 我是 root)它只是挂起.使用 mysql -u root -p
命令,我得到:
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): 无法通过 socket '/var/run/mysqld/mysqld.sock' (2) 连接到本地 MySQL 服务器.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).
然后我尝试手动启动守护进程(mysqld
).提示将挂起约 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] 无法创建 unix socket 锁文件/var/run/mysqld/mysqld.sock.lock.
2016-01-22T19:18:32.399622Z 0 [ERROR] 无法设置 unix socket 锁定文件.
2016-01-22T19:18:32.399646Z 0 [错误] 中止
然后我尝试了 chown mysql/var/run/mysqld
、chmod -R 775/var/run/mysqld
和 apt-get install mysql-community-server --reinstall
.没有运气.
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?
注意:我正在使用 MySQL 社区服务器 5.7.10 运行 Debian 8 (Jessie)
Note: I am Running Debian 8 (Jessie) with MySQL community Server 5.7.10
推荐答案
已修复.在[mysqld]
下的my.cnf
中添加skip-external-locking
,然后重启整个系统.对于任何发现此问题的人,这应该可以解决它.此外,如果您备份了数据,然后尝试恢复并被告知 rm ib*
使其工作,则您需要 ibdata
文件.
Fixed. Add skip-external-locking
to my.cnf
under 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 ibdata
file.
这篇关于MySQL守护进程锁问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!