在重启阿里的CentOS7服务器后,重启MySQL 出现错误

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]

按照提示查看错误信息

[root@djaljdw ~]# systemctl status mysqld.service

● mysqld.service - SYSV: MySQL database server.
Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu -- :: CST; 1min 25s ago
Docs: man:systemd-sysv-generator()
Process: ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=/FAILURE) Aug :: izw91diu854rguz systemd[]: Starting SYSV: MySQL database server....
Aug :: izw91diu854rguz mysqld[]: MySQL Daemon failed to start.
Aug :: izw91diu854rguz mysqld[]: Starting mysqld: [FAILED]
Aug :: izw91diu854rguz systemd[]: mysqld.service: control process exited, code=exited status=
Aug :: izw91diu854rguz systemd[]: Failed to start SYSV: MySQL database server..
Aug :: izw91diu854rguz systemd[]: Unit mysqld.service entered failed state.
Aug :: izw91diu854rguz systemd[]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

[root@djaljdw ~]#  journalctl -xe

--
-- Unit session-.scope has begun starting up.
Jan :: spark01 sshd[]: pam_unix(sshd:session): session opened for user spark by (uid=)
Jan :: spark01 su[]: (to root) spark on pts/
Jan :: spark01 su[]: pam_unix(su-l:session): session opened for user root by spark(uid=)
Jan :: spark01 polkitd[]: Registered Authentication Agent for unix-process::
(system bus name :1.25
Jan :: spark01 systemd[]: Starting SYSV: MySQL database server....
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has begun starting up.
Jan :: spark01 mysqld[]: MySQL Daemon failed to start.
Jan :: spark01 mysqld[]: Starting mysqld: [FAILED]
Jan :: spark01 systemd[]: mysqld.service: control process exited, code=exited status=
Jan :: spark01 systemd[]: Failed to start SYSV: MySQL database server..
-- Subject: Unit mysqld.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has failed.
--
-- The result is failed.
Jan :: spark01 systemd[]: Unit mysqld.service entered failed state.
Jan :: spark01 systemd[]: mysqld.service failed.
Jan :: spark01 polkitd[]: Unregistered Authentication Agent for unix-process::
(system bus name :.

发现里面并没有提供有用的错误信息

所以去查看mysql日志信息(/var/log/mysqld.log)

 :: [Note] Plugin 'FEDERATED' is disabled.
:: InnoDB: The InnoDB memory heap is disabled
:: InnoDB: Mutexes and rw_locks use GCC atomic builtins
:: InnoDB: Compressed tables use zlib 1.2.
:: InnoDB: Using Linux native AIO
:: InnoDB: Initializing buffer pool, size = 128.0M
:: InnoDB: Completed initialization of buffer pool
:: InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
:: InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
:: InnoDB: Waiting for the background threads to start
:: InnoDB: 5.5. started; log sequence number
:: [Note] Server hostname (bind-address): '0.0.0.0'; port:
:: [Note] - '0.0.0.0' resolves to '0.0.0.0';
:: [Note] Server socket created on IP: '0.0.0.0'.
:: [ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
:: [ERROR] Can't start server: can't create PID file: No such file or directory

问题找到了:不能创建PID文件:没有这样的文件或目录

于是去查看,果然没有文件夹

[root@djaljdw ~]#  cd /var/run
[root@djaljdw ~]#  mkdir mysqld
[root@djaljdw ~]#  cd mysqld
[root@djaljdw ~]#  touch mysqld.pid
重启服务还是报错
于是又查看日志
 :: [Note] Plugin 'FEDERATED' is disabled.
:: InnoDB: The InnoDB memory heap is disabled
:: InnoDB: Mutexes and rw_locks use GCC atomic builtins
:: InnoDB: Compressed tables use zlib 1.2.
:: InnoDB: Using Linux native AIO
:: InnoDB: Initializing buffer pool, size = 128.0M
:: InnoDB: Completed initialization of buffer pool
:: InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
:: InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
:: InnoDB: Waiting for the background threads to start
:: InnoDB: 5.5. started; log sequence number
:: [Note] Server hostname (bind-address): '0.0.0.0'; port:
:: [Note] - '0.0.0.0' resolves to '0.0.0.0';
:: [Note] Server socket created on IP: '0.0.0.0'.
:: [ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
:: [ERROR] Can't start server: can't create PID file: Permission denied

发现:无法创建PID文件:权限被拒绝

解决办法:
修改 /var/run/mysqld/权限为mysql 
[root@djaljdw ~]#  chown -R mysql /var/run/mysqld
[root@djaljdw ~]#  chgrp -R mysql /var/run/mysqld
[root@djaljdw ~]#  chmod 777 /var/run/mysqld

重启服务完美解决

tip:看日志是解决问题的一个很好的办法!

CentOS7下MySQL服务启动失败原因及解决方法的更多相关文章

  1. CentOS 7下MySQL服务启动失败的解决思路

    今天,启动MySQL服务器失败,如下所示: [root@spark01 ~]# /etc/init.d/mysqld start Starting mysqld (via systemctl): Jo ...

  2. CentOS下,mysql服务启动失败

    mysql服务启动失败,可以使用排除法查找原因: 如果修改了my.cnf后重启mysql服务失败,大多数情况下都是配置文件有错误, 可以通过备份原来的配置文件,然后将配置文件清空,只剩下[mysqld ...

  3. 玩转Windows服务系列——无COM接口Windows服务启动失败原因及解决方案

    将VS创建的Windows服务项目编译生成的程序,通过命令行 “服务.exe -Service”注册为Windows服务后,就可以通过服务管理器进行管理了. 问题 通过服务管理器进行启动的时候,发现服 ...

  4. phpStudy启动失败时的解决方法

    phpStudy启动失败时的解决方法 phpStudy启动失败,原因一是防火墙拦截,二是80端口已经被别的程序占用,如IIS,迅雷等:三是没有安装VC9运行库,php和apache都是VC9编译.解决 ...

  5. 破解windows下MySQL服务启动不了的情况下不能对其进行全然卸载的解决方式

    下面的文章主要介绍的是在MySQL服务启动不了的情况下,不能对其进行全然卸载的实际解决的方法的描写叙述,下面就是对解决MySQL服务启动不了的情况下详细方案的描写叙述,希望在你今后的学习中会对你有所帮 ...

  6. windows无法启动MySQL服务报错1067的解决方法是怎样?

    方法一: 1.打开my.ini文件,找到default-storage-engine=InnoDB这一行,把它改成default-storage-engine=MyISAM.2.删除在MySQL安装目 ...

  7. tomcat下服务启动失败原因

    Tomcat启动成功,输入网址后可以显示小黄猫界面,但是在Tomcat下的服务却启动不成功,显示404(以Jenkins为例,运用多种方式查看原因) 注:1.单启动Tomcat服务是可以启动成功的. ...

  8. mysql 服务启动失败

    mysql 数据库连接失败 1.用naviCat Preiumn 连接本地的mysql 失败,查找原因,mysql 数据库服务没有启用,但是在服务列表里面没有找到对应的mysql 服务. 所以在cmd ...

  9. 因为曾经装过Mysql导致再次装时windows无法启动MySQL服务报错1067的解决方法

    找到这里 MySQL右击属性 检查这里的可执行文件的路径是否正确,因为我这里显示的是原先的文件夹所以会一直启动失败,修改一下 这里你去百度经验 windows服务修改可执行文件路径 网址https:/ ...

随机推荐

  1. 8.JavaScript

    1.JavaScript简介 JavaScript主要运行在客户端,用户访问带有JavaScript的网页,网页里的JavaScript程序就会传给浏览器,由浏览器解释和处理.表单数据的有效性验证等互 ...

  2. 学习andriod开发之 异步加载图片(二)--- 使用其他进度条

    大家好 我是akira上一节 我们讲到使用AsyncTask 这个类进行异步的下载 主要是涉及到一些图片的更新 这次我们继续上一个demo的改进 . 不知道你是否发现一个问题 上一节我们遗留了两个bu ...

  3. MySQL_(Java)使用JDBC创建用户名和密码校验查询方法

    MySQL_(Java)使用JDBC向数据库发起查询请求 传送门 MySQL数据库中的数据,数据库名garysql,表名garytb,数据库中存在的用户表 通过JDBC对MySQL中的数据用户名和密码 ...

  4. vue 使用axios 出现跨域请求的两种解决方法

    最近在使用vue axios发送请求,结果出现跨域问题,网上查了好多,发现有好几种结局方案. 1:服务器端设置跨域 header(“Access-Control-Allow-Origin:*”); h ...

  5. selenium_java

    等待 页面全加载 ChromeOptions options=new ChromeOptions(); /** *(1) NONE: 当html下载完成之后,不等待解析完成,selenium会直接返回 ...

  6. 【转】C++ 资源大全中文版

    转自:http://www.cnblogs.com/liuliu-NoGirl/p/5802765.html  感谢作者发布这么东西 我想很多程序员应该记得 GitHub 上有一个 Awesome – ...

  7. 我非要捅穿这 Neutron(四)Open vSwitch in Neutron

    目录 文章目录 目录 前文列表 OvS In Neutron 网络拓扑 OvS In Neutron 网络实现模型 双节点混合平面网络 双节点网络拓扑 OvS Bridges 与初始流表项 OvS b ...

  8. 使用gimp画线、矩形、圆等

    使用gimp画线.矩形.圆等 https://blog.csdn.net/tody_guo/article/details/7628508 2012年06月03日 19:08:47 Tody Guo  ...

  9. springboot中静态属性/静态方法从YAML(yml)读取配置属性

    启动类添加注解@EnableConfigurationProperties import jnetman.session.SnmpPref; import org.springframework.bo ...

  10. python爬虫小实例

    1.python爬取贴吧壁纸 1.1.获取整个页面数据 #coding=utf-8 import urllib def getHtml(url): page = urllib.urlopen(url) ...