首页 > 代码库 > 阿里云CentOS 7.2 MySQL服务启动失败的解决思路
阿里云CentOS 7.2 MySQL服务启动失败的解决思路
阿里云 CentOS 7.2 MySQL服务启动失败的解决思路
前言 :
昨天刚刚搭建好的MySQL让老大看了一下,经过测试已经完成任务。但是今天早晨来的时候发现服务器被关了,此时我的心情崩溃的,但是我非常冷静的解决了MySQL问题。如下:
启动MySQL服务器失败,如下所示:
[root@spark01 ~]# /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查看服务启动失败的原因
[root@spark01 ~]# 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.
[root@spark01 ~]# 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服务
[root@spark01 ~]# mkdir -p /var/run/mysqld/
[root@spark01 ~]# /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服务启动失败的解决思路
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。