mysqld.service failed because the control process exited with error code

在尝试启动MySQL服务时遇到错误,日志显示无法创建或写入'/var/run/mysqld/mysqld.pid'文件,错误代码为2(No such file or directory)和13(Permission denied)。通过检查目录权限,创建必要的文件并更改权限,最终成功启动了MySQL服务。
摘要由CSDN通过智能技术生成

[root@k8s-master ~]# service 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.

cat /etc/my.cnf

查看配置文件,日志文件路径:/var/log/mysqld.log

[root@k8s-master ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


#skip-grant-tables

cat /var/log/mysqld.log 

查看日志文件

2022-09-04T11:33:55.617350Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-09-04T11:33:55.619286Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.17) starting as process 19642 ...
2022-09-04T11:33:55.624225Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-09-04T11:33:55.624297Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-09-04T11:33:55.624309Z 0 [Note] InnoDB: Uses event mutexes
2022-09-04T11:33:55.624315Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2022-09-04T11:33:55.624324Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2022-09-04T11:33:55.624332Z 0 [Note] InnoDB: Using Linux native AIO
2022-09-04T11:33:55.624639Z 0 [Note] InnoDB: Number of pools: 1
2022-09-04T11:33:55.624842Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-09-04T11:33:55.627378Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-09-04T11:33:55.647120Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-09-04T11:33:55.651488Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-09-04T11:33:55.667584Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-09-04T11:33:55.669329Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 3769779581
2022-09-04T11:33:55.812871Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775022080
2022-09-04T11:33:55.820068Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775263890
2022-09-04T11:33:55.993003Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3774759936
2022-09-04T11:33:56.006272Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775263890
2022-09-04T11:33:56.009038Z 0 [Note] InnoDB: Database was not shutdown normally!
2022-09-04T11:33:56.009066Z 0 [Note] InnoDB: Starting crash recovery.
2022-09-04T11:33:56.020807Z 0 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2022-09-04T11:33:56.536051Z 0 [Note] InnoDB: Apply batch completed
2022-09-04T11:33:56.640659Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-09-04T11:33:56.640726Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-09-04T11:33:56.640866Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-09-04T11:33:56.939236Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-09-04T11:33:56.940164Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2022-09-04T11:33:56.940185Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-09-04T11:33:56.941182Z 0 [Note] InnoDB: Waiting for purge to start
2022-09-04T11:33:56.991427Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 3775263890
2022-09-04T11:33:56.992055Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-09-04T11:33:56.992398Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-09-04T11:33:56.993483Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220904 19:33:56
2022-09-04T11:33:56.997844Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-09-04T11:33:56.998249Z 0 [Warning] CA certificate ca.pem is self signed.
2022-09-04T11:33:57.000980Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2022-09-04T11:33:57.001034Z 0 [Note] IPv6 is available.
2022-09-04T11:33:57.001047Z 0 [Note]   - '::' resolves to '::';
2022-09-04T11:33:57.001071Z 0 [Note] Server socket created on IP: '::'.
2022-09-04T11:33:57.022718Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2022-09-04T11:33:57.022753Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory
2022-09-04T11:38:10.362882Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-09-04T11:38:10.364829Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.17) starting as process 20409 ...
2022-09-04T11:38:10.369686Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-09-04T11:38:10.369741Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-09-04T11:38:10.369749Z 0 [Note] InnoDB: Uses event mutexes
2022-09-04T11:38:10.369754Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2022-09-04T11:38:10.369758Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2022-09-04T11:38:10.369765Z 0 [Note] InnoDB: Using Linux native AIO
2022-09-04T11:38:10.370094Z 0 [Note] InnoDB: Number of pools: 1
2022-09-04T11:38:10.370214Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-09-04T11:38:10.372292Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-09-04T11:38:10.381280Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-09-04T11:38:10.384049Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-09-04T11:38:10.397180Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-09-04T11:38:10.398706Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 3769779581
2022-09-04T11:38:10.528267Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775022080
2022-09-04T11:38:10.535658Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775263931
2022-09-04T11:38:10.660751Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3774759936
2022-09-04T11:38:10.675574Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 3775263931
2022-09-04T11:38:10.678263Z 0 [Note] InnoDB: Database was not shutdown normally!
2022-09-04T11:38:10.678290Z 0 [Note] InnoDB: Starting crash recovery.
2022-09-04T11:38:10.696002Z 0 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
2022-09-04T11:38:11.225512Z 0 [Note] InnoDB: Apply batch completed
2022-09-04T11:38:11.330737Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-09-04T11:38:11.330800Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-09-04T11:38:11.330881Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-09-04T11:38:11.346434Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-09-04T11:38:11.347306Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2022-09-04T11:38:11.347327Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-09-04T11:38:11.357178Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 3775263931
2022-09-04T11:38:11.357473Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-09-04T11:38:11.379327Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-09-04T11:38:11.381859Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220904 19:38:11
2022-09-04T11:38:11.387283Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-09-04T11:38:11.387787Z 0 [Warning] CA certificate ca.pem is self signed.
2022-09-04T11:38:11.390931Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2022-09-04T11:38:11.391017Z 0 [Note] IPv6 is available.
2022-09-04T11:38:11.391039Z 0 [Note]   - '::' resolves to '::';
2022-09-04T11:38:11.391064Z 0 [Note] Server socket created on IP: '::'.
2022-09-04T11:38:11.395498Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)
2022-09-04T11:38:11.395546Z 0 [ERROR] Can't start server: can't create PID file: Permission denied

处理:

[root@k8s-master ~]# 
[root@k8s-master ~]# cd /var/run
[root@k8s-master run]# 
[root@k8s-master run]# mkdir mysqld
mkdir: cannot create directory ‘mysqld’: File exists
[root@k8s-master run]# 
[root@k8s-master run]# cd mysqld
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# touch mysqld.pid sync
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# chown -R root /var/run/mysqld
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# chgrp -R root /var/run/mysqld
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# chmod 777 /var/run/mysqld
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# systemctl start mysqld
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# 
[root@k8s-master mysqld]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> 
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> 
mysql> 
mysql> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"Job for mysqld.service failed because the control process exited with error code" 这个错误提示表明MySQL的控制进程退出并且返回了错误代码。该错误通常是由于一些配置问题或者系统资源不足引起的。要解决这个问题,你可以按照以下步骤进行操作: 1. 首先,你可以使用命令 "systemctl status mysqld.service" 来查看更详细的错误信息。这会显示出MySQL服务的状态和错误日志。请确保你已经正确安装和配置了MySQL,并检查日志中是否有任何明显的错误信息。 2. 如果你在日志中找到了错误信息,可以根据错误提示进行相应的修复。常见的问题包括数据库文件的权限问题、配置文件错误、端口占用等。请仔细检查并修复这些问题。 3. 如果你无法找到明显的错误信息,你还可以尝试运行命令 "journalctl -xe" 来查看系统日志中的其他错误信息。这些错误可能与MySQL服务相关或者是其他系统组件的问题。请仔细阅读日志并根据提示进行修复。 总之,当出现"Job for mysqld.service failed because the control process exited with error code"错误时,你应该先查看系统日志和MySQL服务状态,找到具体的错误信息,并根据提示进行相应的修复。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Job for mysqld.service failed because the control process exited with error code.](https://blog.csdn.net/yujinlong2002/article/details/128555984)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [解决MySQL因不能创建 PID 导致无法启动的方法](https://download.csdn.net/download/weixin_38519660/13698119)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值