centos7重啟mysql服務?錯誤信息如下:[root@localhost ~]# mysql -uroot -p,下面我們就來聊聊關于centos7重啟mysql服務?接下來我們就一起去了解一下吧!
錯誤信息如下:
[root@localhost ~]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
[root@localhost ~]# /etc/init.d/mysqld start
Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[失敗]
錯誤産生的原因是:
MySQL服務在啟動的時候,不能創建pid文件。
解決辦法:
創建了/var/run/mysqld/目錄,重啟MySQL服務
實際步驟:
1. 創建相關目錄,命令如下:
mkdir -p /var/run/mysqld/
2.再次嘗試啟動:
/etc/init.d/mysqld start
[root@localhost ~]# /etc/init.d/mysqld start
Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[失敗]
依舊啟動失敗,問題原因在于 /var/run/mysqld/的屬主和屬組還是root,mysql并不能在其中創建文件,後修改該目錄的屬主和屬組,啟動OK。
解決步驟:
1.查看相關目錄所屬權限
ls -ld /var/run/mysqld/
[root@localhost ~]# ls -ld /var/run/mysqld/
drwxr-xr-x. 2 root root 40 7月 4 19:01 /var/run/mysqld/
2.修改權限:
chown mysql.mysql /var/run/mysqld/
[root@localhost ~]# chown mysql.mysql /var/run/mysqld/
3.最後再次嘗試重新啟動
[root@localhost ~]# /etc/init.d/mysqld start
Starting mysqld (via systemctl): [ 确定 ]
至此,最後啟動成功!!
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!