CentOS7下MySQL服务启动失败原因及解决方法
程序员文章站
2023-11-18 16:09:10
在重启阿里的CentOS7服务器后,重启MySQL 出现错误 按照提示查看错误信息 [root@djaljdw ~]# systemctl status mysqld.service [root@djaljdw ~]# journalctl -xe 发现里面并没有提供有用的错误信息 所以去查看mys ......
在重启阿里的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 2019-08-22 14:42:39 cst; 1min 25s ago docs: man:systemd-sysv-generator(8) process: 2427 execstart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/failure) aug 22 14:42:37 izw91diu854rguz systemd[1]: starting sysv: mysql database server.... aug 22 14:42:39 izw91diu854rguz mysqld[2427]: mysql daemon failed to start. aug 22 14:42:39 izw91diu854rguz mysqld[2427]: starting mysqld: [failed] aug 22 14:42:39 izw91diu854rguz systemd[1]: mysqld.service: control process exited, code=exited status=1 aug 22 14:42:39 izw91diu854rguz systemd[1]: failed to start sysv: mysql database server.. aug 22 14:42:39 izw91diu854rguz systemd[1]: unit mysqld.service entered failed state. aug 22 14:42:39 izw91diu854rguz systemd[1]: mysqld.service failed. hint: some lines were ellipsized, use -l to show in full.
[root@djaljdw ~]# journalctl -xe
-- -- unit session-2.scope has begun starting up. jan 20 18:26:48 spark01 sshd[2916]: pam_unix(sshd:session): session opened for user spark by (uid=0) jan 20 18:26:52 spark01 su[2944]: (to root) spark on pts/1 jan 20 18:26:52 spark01 su[2944]: pam_unix(su-l:session): session opened for user root by spark(uid=1000) jan 20 18:26:56 spark01 polkitd[909]: registered authentication agent for unix-process:2974:117137 (system bus name :1.25 jan 20 18:26:56 spark01 systemd[1]: 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 20 18:26:57 spark01 mysqld[2979]: mysql daemon failed to start. jan 20 18:26:57 spark01 mysqld[2979]: starting mysqld: [failed] jan 20 18:26:57 spark01 systemd[1]: mysqld.service: control process exited, code=exited status=1 jan 20 18:26:57 spark01 systemd[1]: 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 20 18:26:57 spark01 systemd[1]: unit mysqld.service entered failed state. jan 20 18:26:57 spark01 systemd[1]: mysqld.service failed. jan 20 18:26:57 spark01 polkitd[909]: unregistered authentication agent for unix-process:2974:117137 (system bus name :1.
发现里面并没有提供有用的错误信息
所以去查看mysql日志信息(/var/log/mysqld.log)
190822 14:44:42 [note] plugin 'federated' is disabled. 190822 14:44:42 innodb: the innodb memory heap is disabled 190822 14:44:42 innodb: mutexes and rw_locks use gcc atomic builtins 190822 14:44:42 innodb: compressed tables use zlib 1.2.3 190822 14:44:42 innodb: using linux native aio 190822 14:44:42 innodb: initializing buffer pool, size = 128.0m 190822 14:44:42 innodb: completed initialization of buffer pool 190822 14:44:42 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! 190822 14:44:42 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... 190822 14:44:42 innodb: waiting for the background threads to start 190822 14:44:43 innodb: 5.5.59 started; log sequence number 1940403 190822 14:44:43 [note] server hostname (bind-address): '0.0.0.0'; port: 3306 190822 14:44:43 [note] - '0.0.0.0' resolves to '0.0.0.0'; 190822 14:44:43 [note] server socket created on ip: '0.0.0.0'. 190822 14:44:43 [error] /usr/libexec/mysqld: can't create/write to file '/var/run/mysqld/mysqld.pid' (errcode: 2) 190822 14:44:43 [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
重启服务还是报错
于是又查看日志
190822 14:56:51 [note] plugin 'federated' is disabled. 190822 14:56:51 innodb: the innodb memory heap is disabled 190822 14:56:51 innodb: mutexes and rw_locks use gcc atomic builtins 190822 14:56:51 innodb: compressed tables use zlib 1.2.3 190822 14:56:51 innodb: using linux native aio 190822 14:56:51 innodb: initializing buffer pool, size = 128.0m 190822 14:56:51 innodb: completed initialization of buffer pool 190822 14:56:51 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! 190822 14:56:51 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... 190822 14:56:51 innodb: waiting for the background threads to start 190822 14:56:52 innodb: 5.5.59 started; log sequence number 1940403 190822 14:56:52 [note] server hostname (bind-address): '0.0.0.0'; port: 3306 190822 14:56:52 [note] - '0.0.0.0' resolves to '0.0.0.0'; 190822 14:56:52 [note] server socket created on ip: '0.0.0.0'. 190822 14:56:52 [error] /usr/libexec/mysqld: can't create/write to file '/var/run/mysqld/mysqld.pid' (errcode: 13) 190822 14:56:52 [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服务启动失败原因及解决方法
-
mysql5.7.18安装时mysql服务启动失败的解决方法
-
Win10开机提示user profile service服务登录失败的原因及解决方法
-
steam启动游戏失败错误代码83怎么回事?steam错误代码83的原因及解决方法
-
win10系统提示服务没有及时响应启动或控制请求的原因及2种解决方法
-
npkcrypt服务启动失败的原因及解决办法
-
浅谈python在提示符下使用open打开文件失败的原因及解决方法
-
qt 旧项目编译运行提示 “启动程序失败,路径或者权限错误?” 原因及解决方法
-
CentOS7下MySQL服务启动失败原因及解决方法
-
Java连接数据库(一)mysql:初识XAMPP及Apache服务启动失败的解