一、配置mysql.service 文件
vim /lib/systemd/system/mysql.service
[Unit]
Description=The MySQL server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/etc/init.d/mysql.server start
ExecStop=/etc/init.d/mysql.server stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
123456789101112
:wq
二、重新载入配置文件
systemctl daemon-reload
三、设置为开机自启
systemctl enable mysql.service
四、其他常用命令
systemctl start mysql.service
启动 MySQL 服务
systemctl stop mysql.service
关闭 MySQL 服务
systemctl restart mysql.service
重启 MySQL 服务
systemctl reload mysql.service
重新载入 MySQL 服务
systemctl force-reload mysql.service
强制重新载入 MySQL 服务
systemctl status mysql.service
查看当前 MySQL 服务状态
systemctl enable mysql.service
设置 MySQL 开机自启
systemctl disable mysql.service
禁用 MySQL 开机自启
systemctl is-enabled mysql.service
查看 MySQL 是否开机自启
systemctl list-unit-files
来源:CSDN
作者:NKCJ
链接:https://blog.csdn.net/caijunliyanqing/article/details/103818588