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 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
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故障的錯誤日志不是很清晰,需要經驗和對錯誤日志分析把控。那啥,數據一定要作好日常備份,發生數據災難時也有可以恢復的源。