1. 程式人生 > >centos7 mysql 啟動mysqld.service - SYSV: MySQL database server錯誤

centos7 mysql 啟動mysqld.service - SYSV: MySQL database server錯誤

前段時間安裝好的myql資料庫,一直用的挺好的,結果昨天重啟了一下伺服器後mysql莫名的啟動不了了,狀況如下:

   1.啟動命令

systemctl start mysqld.service 或者 /etc/init.d/mysqld start   結果同樣的錯誤

     2.錯誤是:

      Job for mysqld.service failed. See 'systemctl status mysqld.service' and 'journalctl -xn' for details.

     3.按照提示輸入命令

      systemctl status mysqld.service 或者 journalctl -xn

      命令後提示:

        mysqld.service - SYSV: MySQL database server.
    Loaded: loaded (/etc/rc.d/init.d/mysqld)
    Active: failed (Result: exit-code) since Tue 2017-03-14 09:00:45 CST; 9s ago
 

Process: 2550 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)
  Starting SYSV: MySQL database server....
  MySQL Daemon failed to start.
Starting mysqld:  [FAILED]
mysqld.service: control process exited, code=exited status=1
Failed to start SYSV: MySQL database server..
Unit mysqld.service entered failed state.

    4.進一步檢視日誌:

       vi /var/log/mysqld.log

        如下:

         [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
[ERROR] Can't start server: can't create PID file: No such file or directory

     5.建立該目錄

        mkdir -p /var/run/mysqld/

   6.啟動mysql服務

     /etc/init.d/mysqld start

     錯誤和原來一致

   7.檢視日誌:

     如下:

          [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)
          [ERROR] Can't start server: can't create PID file: Permission denied

   8.授權

      chown mysql.mysql /var/run/mysqld/

   9.啟動

      /etc/init.d/mysqld start
      Starting mysqld (via systemctl):                           [  OK  ]