centos7 systemctl 管理MySQL

[root@ze11 ~]# ll /usr/local/mysql
lrwxrwxrwx. 1 mysql mysql 35 Dec 22 21:52 /usr/local/mysql -> mysql-5.7.25-linux-glibc2.12-x86_64
[root@ze11 ~]# ps -ef |grep mysql
mysql 21747 1 0 22:38 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql_3306/my.cnf --user=mysql
mysql 22491 21747 0 22:38 ? 00:00:01 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql_3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql_3306/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/data/mysql_3306/logs/mysqlerror.log --open-files-limit=65535 --pid-file=/data/mysql_3306/run/8202-IPSSDB1.pid --socket=/data/mysql_3306/run/mysql.sock --port=3306
root 22533 19293 0 22:41 pts/1 00:00:00 grep --color=auto mysql
[root@ze11 ~]# cat /etc/systemd/system/mysql.service|grep -v "#"
[Unit]
Description=MySQL Community Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=mysql.service
[Service]
User=mysql
Group=mysql
PermissionsStartOnly=true
ExecStart=/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql_3306/my.cnf --user=mysql
TimeoutSec=600
Restart=always
PrivateTmp=false
[root@ze11 ~]#

[root@ze11 ~]# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/etc/systemd/system/mysql.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2020-12-22 22:38:44 CST; 2min 54s ago
Main PID: 21747 (mysqld_safe)
CGroup: /system.slice/mysql.service
├─21747 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql_3306/my.cnf --user=mysql
└─22491 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql_3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql_3306/data --plugin-d...

Dec 22 22:38:44 ze11.localdomain systemd[1]: Stopped MySQL Community Server.
Dec 22 22:38:44 ze11.localdomain systemd[1]: Started MySQL Community Server.
Dec 22 22:38:45 ze11.localdomain mysqld_safe[21747]: 2020-12-22T14:38:45.406782Z mysqld_safe Logging to '/data/mysql_3306/logs/mysqlerror.log'.
Dec 22 22:38:45 ze11.localdomain mysqld_safe[21747]: 2020-12-22T14:38:45.459723Z mysqld_safe Starting mysqld daemon with databases from /data/mysql_3306/data
[root@ze11 ~]#

原文地址:https://www.cnblogs.com/elontian/p/14175974.html