首页 > 代码库 > MySQL数据库出现The server quit without updating PID file.

MySQL数据库出现The server quit without updating PID file.

LNMP1.0可以在Linux系统下快速搭建PHP环境,以前操作其它服务器也用过LNMP环境,重未出现过类似错误,现将解决过程记录一下。

一、服务器环境

  操作系统:CentOS-6.4

  服务器环境:集成环境LNMP1.0

二、步骤重现

  1、安装LNMP1.0,具体操作方法见这里,安装成功;

  2、因个人需求,现将MySQL数据库存放在/data/mysql/var,修改/etc/my.cnf的datadir=/data/mysql/var,别忘了将/var目录的权限设置为chown -R mysql.mysql /data/mysql; 

  3、重启服务,/root/lnmp restart;

  4、提示错误:Starting MySQL...The server quit without updating PID file [失败]/mysql/var/localhost.localdomain.pid).;

三、解决错误

  1、根据提示可能是PID的错误,按照常规解决方法kill相关进程、清除selinux,问题仍然存在;

  2、查看错误日志,/usr/local/mysql/var/localhost.localdomain.pid

140513 11:59:34 mysqld_safe Starting mysqld daemon with databases from /data/mysql/var
/usr/local/mysql/bin/mysqld: Table mysql.plugin doesnt exist
140513 11:59:34 [ERROR] Cant open the mysql.plugin table. Please run mysql_upgrade to create it.
140513 11:59:34 InnoDB: The InnoDB memory heap is disabled
140513 11:59:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140513 11:59:34 InnoDB: Compressed tables use zlib 1.2.3
140513 11:59:34 InnoDB: Initializing buffer pool, size = 16.0M
140513 11:59:34 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file /data/mysql/var/ibdata1 did not exist:
InnoDB: a new database to be created!
140513 11:59:34  InnoDB: Setting file /data/mysql/var/ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
140513 11:59:34  InnoDB: Log file /data/mysql/var/ib_logfile0 did not exist: new to be created
InnoDB: Setting log file /data/mysql/var/ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
140513 11:59:34  InnoDB: Log file /data/mysql/var/ib_logfile1 did not exist: new to be created
InnoDB: Setting log file /data/mysql/var/ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
140513 11:59:35  InnoDB: Waiting for the background threads to start
140513 11:59:36 InnoDB: 1.1.8 started; log sequence number 0
140513 11:59:36 [Note] Server hostname (bind-address): 0.0.0.0; port: 3306
140513 11:59:36 [Note]   - 0.0.0.0 resolves to 0.0.0.0;
140513 11:59:36 [Note] Server socket created on IP: 0.0.0.0.
140513 11:59:36 [ERROR] Fatal error: Cant open and lock privilege tables: Table mysql.host doesnt exist
140513 11:59:36 mysqld_safe mysqld from pid file /data/mysql/var/localhost.localdomain.pid ended

  3、根据日志提示,可能是mysql.plugin数据表不存在,拷贝原数据库目录/usr/local/mysql/var/*到/data/mysql/var/,重启mysql服务/etc/init.d/mysql start,发现问题仍然存在;

  4、返回数据库目录查看数据权限发现全是root.root,重新设置数据权限:chown mysql.mysql /data/mysql/,重启mysql服务/etc/init.d/mysql start,问题解决。

四、总结

  在配置Linux环境出现错误再所难免,MySQL故障的错误日志不是很清晰,需要经验和对错误日志分析把控。那啥,数据一定要作好日常备份,发生数据灾难时也有可以恢复的源。