报错:

[root@test leo]# lnmp restart   
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Stoping LNMP...
Stoping nginx...  done
ERROR! MySQL server PID file could not be found!
Gracefully shutting down php-fpm . done
Starting LNMP...
Starting nginx...  done
Starting MySQL.. ERROR! The server quit without updating PID file (/tmp/mysql/mysql.pid).    ##启动数据库的时候报错,PID文件丢失,并不能创建成功。
Starting php-fpm  done
[root@test leo]# ps aux |grep mysql
root      17903  0.0  0.0 103324   852 pts/0    S+   10:30   0:00 grep mysql

解决:

[root@test leo]# vim /etc/my.cnf    #修改MySQL的配置文件
[mysqld]
pid-file = /tmp/mysql/mysql.pid     #添加这一行
[root@test leo]# mkdir -p /tmp/mysql
[root@test leo]# chown mysql.mysql  /tmp/mysql    #设置目录的权限给mysql这个用户
[root@zuitu leo]# lnmp restart
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Stoping LNMP...
Stoping nginx...  done
ERROR! MySQL server PID file could not be found!   ##关闭MySQL服务失败,因为MySQL服务根本没有启动
Gracefully shutting down php-fpm . done 
Starting LNMP...
Starting nginx...  done
Starting MySQL.. SUCCESS!  ##启动MySQL服务成功
Starting php-fpm  done
[root@test leo]# netstat -tunlp  |grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      21188/mysqld        
[root@test leo]#

至此已解决问题,如果数据库中的数据非常重要的话,请不要参考网上那些初始化数据库。

更多的博客转移到个人博客上了,请点击以下链接:
个人博客