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! 

 

  

posted @ 2018-10-01 17:44  xuebusi  阅读(3587)  评论(0编辑  收藏  举报