Tag Archives: Job for mysqld.service failed because the control process exited with error code

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

Open source software supply chain lighting plan, waiting for you>>>

Thrown when starting MySQL:

Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

It is suggested to use journalctl - Xe to view detailed logs

[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.

At the time of discovery, the process already exists. MySQL’s process PID is 3306, so I want to kill the process:

kill 3306

Find out the error, so check the configuration in cat/etc/my.cfg

Finally, it is found that there is a wrong configuration when setting the font encoding, which leads to the failure of startup

[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.

Most of the startup failures are due to the configuration error of the configuration file. You must backup the configuration file in advance