Job for mysqld.service failed because the control process exited with error code
启动MySQL时抛出:
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
提示说使用journalctl -xe
查看详细日志
[linga@localhost ~]$ journalctl -xe -- 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. Aug 30 04:32:12 localhost.localdomain mysqld[2312]: Initialization of mysqld failed: 0 Aug 30 04:32:12 localhost.localdomain systemd[1]: mysqld.service: control process exited, code=exited status=1 Aug 30 04:32:14 localhost.localdomain systemd[1]: Failed to start MySQL 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. Aug 30 04:32:14 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state. Aug 30 04:32:14 localhost.localdomain systemd[1]: mysqld.service failed. Aug 30 04:32:14 localhost.localdomain systemd[1]: mysqld.service holdoff time over, scheduling restart. Aug 30 04:32:14 localhost.localdomain systemd[1]: Starting MySQL 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. Aug 30 04:32:14 localhost.localdomain mysqld[2359]: Initialization of mysqld failed: 0 Aug 30 04:32:14 localhost.localdomain systemd[1]: mysqld.service: control process exited, code=exited status=1 Aug 30 04:32:16 localhost.localdomain systemd[1]: Failed to start MySQL 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. Aug 30 04:32:16 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state. Aug 30 04:32:16 localhost.localdomain systemd[1]: mysqld.service failed.
发现时进程已经存在了,MySQL的进程pid
是3306,于是想着杀掉该进程:
kill 3306
发现报错了,于是在cat /etc/my.cfg
中查看配置
最后发现设置字体编码时弄错配置了,导致启动失败的;
[linga@localhost ~]$ kill 3306 -bash: kill: (3306) - No such process [linga@localhost ~]$ 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 # Add UTF-8 character_set=utf8 init_connect='SET NAMES utf8' [linga@localhost ~]$ sudo vim /etc/my.cnf [sudo] password for linga: [linga@localhost ~]$ sudo systemctl start mysqld [linga@localhost ~]$ sudo systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2018-08-30 04:41:33 EDT; 12s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 14018 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 14001 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 14021 (mysqld) CGroup: /system.slice/mysqld.service └─14021 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid Aug 30 04:41:32 localhost.localdomain systemd[1]: mysqld.service holdoff time over, scheduling restart. Aug 30 04:41:32 localhost.localdomain systemd[1]: Starting MySQL Server... Aug 30 04:41:33 localhost.localdomain systemd[1]: Started MySQL Server.
启动失败大多都是由于配置文件配置出错了才启动不起来,一定要提前备份好配置文件
作者: 咕咚!
出处: https://www.cnblogs.com/linga/
关于作者:专注虚拟化,运维开发,RPA,Rust,Go,Python!
本文版权归作者和博客园共有,禁止*.csdn.net转载,禁止以盈利为目的的转载,转载文章,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 原文链接 如有问题, 可邮件(oldsixa@163.com)咨询.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步