今天有台服务器启动后,执行service mysqld start提示无法启动,但是未输出任何有用的日志信息,具体如下:
[root@localhost bin]# service mysqld start Starting mysqld: [FAILED]
查看日志:
[root@localhost bin]# journalctl -xe Apr 03 20:45:15 localhost 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. Apr 03 20:45:17 localhost mysqld[22569]: MySQL Daemon failed to start. Apr 03 20:45:17 localhost mysqld[22569]: Starting mysqld: [FAILED] Apr 03 20:45:17 localhost systemd[1]: mysqld.service: control process exited, code=exited status=1 Apr 03 20:45:17 localhost systemd[1]: Failed to start SYSV: MySQL database server.. -- Subject: Unit mysqld.service has failed
通过上面信息看不出任何问题,查看mysql错误日志也无日志新增。
解决办法:
通过单独启动mysqld_safe ,查到一些日志信息:
[root@localhost bin]# ./mysqld_safe 2022-04-03T12:56:45.867947Z mysqld_safe Logging to '/var/log/mysqld1.log'. 2022-04-03T12:56:45.895933Z mysqld_safe Starting mysqld daemon with databases from /mnt/data/mysql 2022-04-03T12:56:49.159407Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
日志提示mysql.pid文件ended,判断为/var/run/mysqld/目录没有mysql用户的操作权限。
执行:
chown -R mysql.mysql /var/run/mysqld/ service mysqld start
至此,可以正常启动MySQL。
此次故障为服务器重启后,对/var/run/mysqld/目录操作权限丢失,如果下次遇到启动MySQL无报错的情况,可以尝试单独启动mysqld_safe,可以看到一些报错信息。
您好~我是腾讯云+社区的运营,关注了您分享的技术文章,觉得内容很棒,我们诚挚邀请您加入腾讯云自媒体分享计划。完整福利和申请地址请见:https://cloud.tencent.com/developer/support-plan
作者申请此计划后将作者的文章进行搬迁同步到社区的专栏下,你只需要简单填写一下表单申请即可,我们会给作者提供包括流量、云服务器等,另外还有些周边礼物。