centos下mysql啟動報錯Job for mysqld.servic
阿新 • • 發佈:2020-12-23
技術標籤:錯誤解決
報錯資訊:Job for mysqld.service failed because the control process exited with error code. See “systemctl status mysqld.service” and “journalctl -xe” for details.
檢視日誌:cat /var/log/mysqld.log,尋找原因:
2020-12-15T01:38:38.906381Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-12-15T01:38:38.907027Z 0 [Warning] CA certificate ca.pem is self signed.
2020-12-15T01:38:38.907065Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-12-15T01:38:38.907384Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-12-15T01:38:38.907601Z 0 [Note] IPv6 is available.
2020-12-15T01:38:38.907609Z 0 [Note] - '::' resolves to '::';
2020-12-15T01:38:38.907621Z 0 [Note] Server socket created on IP: '::'.
2020-12-15T01:38:38.913473Z 0 [ERROR] Can't start server: can't check PID filepath: No such file or directory
錯誤原因:[ERROR] Can’t start server: can’t check PID filepath: No such file or directory,這是由於強制關機導致pid檔案丟失
解決方法
1、從mysql的配置檔案中查詢pid檔案路徑:
cat /etc/my.cnf
2、根據第一步路徑建立對應的目錄並修改許可權
mkdir -p /var/run/mysqld
chown mysql.mysql /var/run/mysqld
重啟mysql了,如果還不行繼續第三步
3、建立一個pid檔案並修改許可權
touch /var/run/mysqld/mysqld.pid
chown mysql.mysql /var/run/mysqld/mysqld.pid
再啟動MySQL。基本不會有問題了