Docker容器啟動lnmp環境下的mysql服務時報"MySQL server PID file could not be found"錯誤解決辦法


我在自己的mac筆記本上裝了一個docker,並在docker容器中安裝了lnmp環境,經常會遇到在使用"lnmp restart"命令啟動lnmp服務的時候,mysql服務啟動失敗,啟動日志:

Stoping LNMP...
Stoping nginx... nginx is not running.
 ERROR! MySQL server PID file could not be found!
Gracefully shutting down php-fpm /etc/init.d/php-fpm: line 82: kill: (695) - No such process
................................... failed. Use force-quit
Starting LNMP...
Starting nginx...  done
Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/var/37815a453e3e.pid).
Starting php-fpm  done

 

找到mysql的數據存放目錄,我的是/usr/local/mysql/var目錄下(這個目錄可以通過/etc/my.cnf中的innodb_data_home_dir屬性查看),找到以.err結尾對文件,根據日期查看最近對err文件:

[root@37815a453e3e bin]# cd /usr/local/mysql/var
[root@37815a453e3e var]# ll
total 141556
-rw-r----- 1 mysql mysql    27407 Sep 30 16:29 124dc886567c.err
-rw-r----- 1 mysql mysql     6924 Sep 30 12:55 22415a597457.err
-rw-r----- 1 mysql mysql    20626 Oct  1 17:02 37815a453e3e.err
-rw-r----- 1 mysql mysql    41418 Sep 30 11:05 7f92c9fbcaea.err
-rw-r----- 1 mysql mysql    36378 Sep 29 13:42 f25f067a6a86.err

 

發現錯誤日中有如下錯誤信息:

2018-10-01T14:05:29.741954Z 0 [Warning] Insecure configuration for --pid-file: 
  Location '/usr/local/mysql/var' in the path is accessible to all OS users.
  Consider choosing a different directory.
2018-10-01T14:05:29.744299Z 0 [ERROR] Fatal error: Can't open and lock privilege tables:
  Table storage engine for
'proxies_priv' doesn't have this option 2018-10-01T14:05:29.744399Z 0 [ERROR] Aborting

 

解決辦法,對數據目錄授權:

[root@6e1de98da6d4 var]# chown -R mysql:mysql /usr/local/mysql/var/
[root@6e1de98da6d4 var]# lnmp mysql restart
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
 ERROR! MySQL server PID file could not be found!
Starting MySQL. SUCCESS! 
[root@6e1de98da6d4 var]# 

 

重啟mysql服務,啟動OK:

[root@37815a453e3e var]# lnmp mysql restart
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM