这里的mysql使用docker安装的,mysql的容器id为:c8f60af87695
第一步编写开启mysql容器的shell脚本:start.sh
#!/bin/bash #启动mysql容器,mysql容器id为:c8f60af87695 docker start c8f60af87695
chmod +x start.sh
第二步在/lib/systemd/system/目录下编写mysql.service
内容为:
[Unit] Description=mysqlservice After=network.target [Service] Type=forking ExecStart=/home/kwz/startMysql/start.sh [Install] WantedBy=multi-user.target
设置开机自启动:
systemctl enable mysql.service