centos添加jar包安装的mysql到系统服务
- 创建启动脚本文件,sudo vi /etc/systemd/system/mysql.service
- 编写代码
[Unit]
Description=MySQL Server
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
TimeoutSec=300
[Install]
WantedBy=multi-user.target
- 重新加载并启动服务
sudo systemctl daemon-reload
sudo systemctl restart mysql
sudo systemctl status mysql
- 添加到开机启动
sudo systemctl enable mysql
sudo systemctl is-enabled mysql