Configure MySQL to start on boot with systemd
Configure MySQL to start on boot with systemd
-
Add a systemd service unit configuration file with details about the MySQL service
$> cd /usr/lib/systemd/system
$> touch mysqld.service
$> chmod 644 mysqld.serviceAdd this configuration information to the
mysqld.servicefile[Unit]
Description=MySQL Server
Documentation=man:mysqld(7)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
Type=forking
PIDFile=/usr/local/mysql/data/mysqld.pid
# Disable service start and stop timeout logic of systemd for mysqld service.
TimeoutSec=0
# Start main service
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --daemonize --pid-file=/usr/local/mysql/data/mysqld.pid $MYSQLD_OPTS
# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql
# Sets open_files_limit
LimitNOFILE = 5000
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false -
Add a configuration file for the systemd tmpfiles feature.
$> cd /usr/lib/tmpfiles.d
$> touch mysql.conf
$> chmod 644 mysql.confAdd this configuration information to the
mysql.conffile.d /usr/local/mysql/data 0750 mysql mysql -
-
Enable the mysqld service to automatically start at reboot.
$> systemctl enable mysqld.service --now
$> systemctl status mysqld
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.

