報錯:
[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]#
至此已解決問題,如果數據庫中的數據非常重要的話,請不要參考網上那些初始化數據庫。