centos7 mysql 启动mysqld.service - SYSV: MySQL database server错误

Posted 四海骄阳

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 mysql 启动mysqld.service - SYSV: MySQL database server错误相关的知识,希望对你有一定的参考价值。

 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  ]
————————————————
版权声明:本文为CSDN博主「loveuserzzz」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/loveuserzzz/article/details/62036988

以上是关于centos7 mysql 启动mysqld.service - SYSV: MySQL database server错误的主要内容,如果未能解决你的问题,请参考以下文章

Linux Centos7下如何确认MySQL服务已经启动

centos 7 上配置mysql 开机启动详解

centos7下启动不了mysql或者mariadb报错

Centos7下设置MySql自动启动

求大神解惑,centos7环境已经安装mysql,怎么启动mysql?

centos7编译安装MySQL无法启动解决办法