阿里云CentOS 7.2 MySQL服务启动失败的解决思路
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了阿里云CentOS 7.2 MySQL服务启动失败的解决思路相关的知识,希望对你有一定的参考价值。
阿里云 CentOS 7.2 mysql服务启动失败的解决思路
前言 :
昨天刚刚搭建好的MySQL让老大看了一下,经过测试已经完成任务。但是今天早晨来的时候发现服务器被关了,此时我的心情崩溃的,但是我非常冷静的解决了MySQL问题。如下:
启动MySQL服务器失败,如下所示:
[[email protected] ~]# /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. [FAILED]
根据提示,分别使用systemctl status mysqld.service和journalctl -xe查看服务启动失败的原因
[[email protected] ~]# systemctl status mysqld.service
mysqld.service - SYSV: MySQL database server. Loaded: loaded (/etc/rc.d/init.d/mysqld) Active: failed (Result: exit-code) since Wed 2016-01-20 18:26:57 CST; 40s ago Docs: man:systemd-sysv-generator(8) Process: 2979 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE) spark01 systemd[1]: Starting SYSV: MySQL database server.... spark01 mysqld[2979]: MySQL Daemon failed to start.spark01 mysqld[2979]: Starting mysqld: [FAILED] spark01 systemd[1]: mysqld.service: control process exited, code=exited status=1Jan 20 18:26:57 spark01 systemd[1]: Failed to start SYSV: MySQL database server.. spark01 systemd[1]: Unit mysqld.service entered failed state. spark01 systemd[1]: mysqld.service failed.
[[email protected] ~]# journalctl -xe
但,可惜的时,这些信息并不能提供服务启动失败的真正原因。
这时候,不妨打开MySQL的告警日志,毕竟,只要MySQL服务启动,告警日志都会有输出信息的,果然
2017-06-6T09:00:19.935771Z 0 [ERROR] /usr/sbin/mysqld: Can‘t create/write to file ‘/var/run/mysqld/mysqld.pid‘ (Errcode: 2 - No such file or directory)2017-06-20T10:00:19.935795Z 0 [ERROR] Can‘t start server: can‘t create PID file: No such file or directory160120 18:00:20 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
MySQL服务在启动的时候,不能创建pid文件。
在终端看一下该目录是否存在,果然,不存在。
于是,创建了/var/run/mysqld/目录,重启MySQL服务
[[email protected] ~]# mkdir -p /var/run/mysqld/
[[email protected] ~]# /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. [FAILED]
依旧报错,重新查看告警日志,有以下输出
2017-06-6T09:28:37.183387Z 0 [ERROR] /usr/sbin/mysqld: Can‘t create/write to file ‘/var/run/mysqld/mysqld.pid‘ (Errcode: 13 - Permission denied)2016-01-20T10:28:37.183431Z 0 [ERROR] Can‘t start server: can‘t create PID file: Permission denied160120 18:28:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended160120 18:32:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
本文出自 “李世龙” 博客,谢绝转载!
以上是关于阿里云CentOS 7.2 MySQL服务启动失败的解决思路的主要内容,如果未能解决你的问题,请参考以下文章
来都来了,你确定不看看,阿里云服务器Centos8安装MySQL8.0!!(图文并茂版!!!)
CentOS 7.2 安装配置 Percona Server