启动mysql Job for mysqld.service failed because the control process exited with error code. See "syste

本文记录了一次解决Linux下MySQL服务启动失败的问题,主要错误为无法创建PID文件。通过检查相关目录,创建缺失的/var/run/mysqld/目录,并调整其权限至mysql用户,最终成功启动MySQL服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天你重启linux后,启动mysql一直报错 Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
                                                           [FAILED]

然后去查看mysql启动日志,无奈太多行。

查看最后20行:tail -n 20  /var/log/mysqld.log

错误如下:

2018-10-08T02:54:57.635255Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-10-08T02:54:57.686614Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-10-08T02:54:57.715292Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-10-08T02:54:57.728284Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-10-08T02:54:57.771885Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-10-08T02:54:57.771922Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-10-08T02:54:57.772052Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-10-08T02:54:58.021555Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-10-08T02:54:58.022600Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-10-08T02:54:58.022624Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-10-08T02:54:58.023805Z 0 [Note] InnoDB: 5.7.23 started; log sequence number 190663054
2018-10-08T02:54:58.023982Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-10-08T02:54:58.024119Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-10-08T02:54:58.031317Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-10-08T02:54:58.031664Z 0 [Warning] CA certificate ca.pem is self signed.
2018-10-08T02:54:58.033871Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2018-10-08T02:54:58.034201Z 0 [Note] IPv6 is available.
2018-10-08T02:54:58.034214Z 0 [Note]   - '::' resolves to '::';
2018-10-08T02:54:58.034243Z 0 [Note] Server socket created on IP: '::'.
2018-10-08T02:54:58.041954Z 0 [ERROR] Can't start server: can't check PID filepath: No such file or directory

 

最主要是最后一行错误

MySQL服务在启动的时候,不能创建pid文件。

在终端看一下该目录是否存在,果然,不存在。

于是,创建了/var/run/mysqld/目录,重启MySQL服务

mkdir -p /var/run/mysqld/

/etc/init.d/mysqld start

依旧报错

原来,/var/run/mysqld/的属主和属组还是root,mysql并不能在其中创建文件,后修改该目录的属主和属组,启动OK

[root@ebs-46753 /]# ls -ld /var/run/mysqld/
drwxr-xr-x. 2 root root 40 10月  8 11:07 /var/run/mysqld/
[root@ebs-46753 /]# chown mysql.mysql /var/run/mysqld/
[root@ebs-46753 /]# cd
[root@ebs-46753 ~]# service mysqld start
Starting mysqld (via systemctl):                           [  OK  ]
[root@ebs-46753 ~]# 
 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值