解决MySQL服务器断电后出现:The server quit without updating PID file

作者: admin 分类: 运维那些事 发布时间: 2017-06-30 14:33

问题描述

本地测试服务器不小心断电了,导致MySQL启动出错,具体错误如下

[root@TestServer var]# service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/data/database/var/TestServer.pid).

解决办法

首先排除是权限问题,然后查看mysql错误日志

[root@TestServer var]# cat TestServer.err
170630 13:47:22 mysqld_safe Starting mysqld daemon with databases from /data/database/var
2017-06-30 13:47:22 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-06-30 13:47:22 8099 [Note] Plugin 'FEDERATED' is disabled.
2017-06-30 13:47:22 7f8629cd7720 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.


#loose-innodb-ft-deleted=0
2017-06-30 13:47:22 8099 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-06-30 13:47:22 8099 [Note] InnoDB: The InnoDB memory heap is disabled
2017-06-30 13:47:22 8099 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-06-30 13:47:22 8099 [Note] InnoDB: Memory barrier is not used
2017-06-30 13:47:22 8099 [Note] InnoDB: Compressed tables use zlib 1.2.3


#loose-innodb-sys-foreign=0
2017-06-30 13:47:22 8099 [Note] InnoDB: Using CPU crc32 instructions
2017-06-30 13:47:22 8099 [Note] InnoDB: Initializing buffer pool, size = 16.0M
2017-06-30 13:47:22 8099 [Note] InnoDB: Completed initialization of buffer pool
2017-06-30 13:47:22 8099 [Note] InnoDB: Highest supported file format is Barracuda.
2017-06-30 13:47:22 8099 [Note] InnoDB: The log sequence numbers 65747352 and 65747352 in ibdata files do not match the log sequence number 244978765 in the ib_logfiles!
2017-06-30 13:47:22 8099 [Note] InnoDB: Database was not shutdown normally!
2017-06-30 13:47:22 8099 [Note] InnoDB: Starting crash recovery.
2017-06-30 13:47:22 8099 [Note] InnoDB: Reading tablespace information from the .ibd files...
2017-06-30 13:47:22 7f8629cd7720  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: Error: could not open single-table tablespace file ./test_abc/django_content_type.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
170630 13:47:22 mysqld_safe mysqld from pid file /data/database/var/TestServer.pid ended

分析日志发现:
没有权限、不能打开.ibd文件,可能这个损坏了

InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: Error: could not open single-table tablespace file ./test_abc/django_content_type.ibd

再接着看,

InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf

已经给出了建议,直接在/etc/my.cnf文件设置innodb_force_recovery=1,强制启动

[root@TestServer var]# service mysql start
Starting MySQL..... SUCCESS!

嗯,成功启动了!删除这个设置,重启MySQL!搞定!

(完)

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注