LNMP1.0能够在Linux系统下快速搭建PHP环境,之前操做其它服务器也用过LNMP环境,重未出现过相似错误,现将解决过程记录一下。html
1、服务器环境mysql
操做系统:CentOS-6.4linux
服务器环境:集成环境LNMP1.0sql
2、步骤重现数据库
一、安装LNMP1.0,具体操做方法见这里,安装成功;服务器
二、因我的需求,现将MySQL数据库存放在/data/mysql/var,修改/etc/my.cnf的datadir=/data/mysql/var,别忘了将/var目录的权限设置为chown -R mysql.mysql /data/mysql; dom
三、重启服务,/root/lnmp restart;socket
四、提示错误:Starting MySQL...The server quit without updating PID file [失败]/mysql/var/localhost.localdomain.pid).;ui
3、解决错误atom
一、根据提示多是PID的错误,按照常规解决方法kill相关进程、清除selinux,问题仍然存在;
二、查看错误日志,/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 exist 140513 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 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: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 140513 11:59:36 mysqld_safe mysqld from pid file /data/mysql/var/localhost.localdomain.pid ended
三、根据日志提示,多是mysql.plugin数据表不存在,拷贝原数据库目录/usr/local/mysql/var/*到/data/mysql/var/,重启mysql服务/etc/init.d/mysql start,发现问题仍然存在;
四、返回数据库目录查看数据权限发现全是root.root,从新设置数据权限:chown mysql.mysql /data/mysql/,重启mysql服务/etc/init.d/mysql start,问题解决。;
4、总结
在配置Linux环境出现错误再所不免,MySQL故障的错误日志不是很清晰,须要经验和对错误日志分析把控。那啥,数据必定要做好平常备份,发生数据灾难时也有能够恢复的源。