cat < /usr/lib/systemd/system/mysql.service
[Unit]
Description=MySQL Server
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=forking
TimeoutSec=0
PermissionsStartOnly=true
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --daemonize
LimitNOFILE = 65535
Restart=on-failure
RestartSec=10
RestartPreventExitStatus=1
PrivateTmp=false
EOF
#添加可执行权限:
chmod 755 /usr/lib/systemd/system/mysql.service
#重载 systemctl units
systemctl daemon-reload
#设置为开机自启动
systemctl enable mysql.service