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' doesn't exist140513 11:59:34 [error] can't open the mysql.plugin table. please run mysql_upgrade to create it.140513 11:59:34 innodb: the innodb memory heap is disabled140513 11:59:34 innodb: mutexes and rw_locks use gcc atomic builtins140513 11:59:34 innodb: compressed tables use zlib 1.2.3140513 11:59:34 innodb: initializing buffer pool, size = 16.0m140513 11:59:34 innodb: completed initialization of buffer poolinnodb: 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 mbinnodb: 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 createdinnodb: setting log file /data/mysql/var/ib_logfile0 size to 5 mbinnodb: 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 createdinnodb: setting log file /data/mysql/var/ib_logfile1 size to 5 mbinnodb: database physically writes the file full: wait...innodb: doublewrite buffer not found: creating newinnodb: doublewrite buffer createdinnodb: 127 rollback segment(s) active.innodb: creating foreign key constraint system tablesinnodb: foreign key constraint system tables created140513 11:59:35 innodb: waiting for the background threads to start140513 11:59:36 innodb: 1.1.8 started; log sequence number 0140513 11:59:36 [note] server hostname (bind-address): '0.0.0.0'; port: 3306140513 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: can't open and lock privilege tables: table 'mysql.host' doesn't exist140513 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故障的错误日志不是很清晰,需要经验和对错误日志分析把控。那啥,数据一定要作好日常备份,发生数据灾难时也有可以恢复的源。