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 : kill: () - 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
-rw-r----- mysql mysql Sep : 124dc886567c.err
-rw-r----- mysql mysql Sep : 22415a597457.err
-rw-r----- mysql mysql Oct : 37815a453e3e.err
-rw-r----- mysql mysql Sep : 7f92c9fbcaea.err
-rw-r----- mysql mysql Sep : f25f067a6a86.err

发现错误日中有如下错误信息:

--01T14::.741954Z  [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.
--01T14::.744299Z [ERROR] Fatal error: Can't open and lock privilege tables:
  Table storage engine for 'proxies_priv' doesn't have this option
--01T14::.744399Z [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!


上一篇:Java代理和动态代理


下一篇:mac开机启动apache、memcached与mysql