Centos7下设置mysql自启动
环境:
OS:Centos 7
DB:mysql 5730
设置开机自启动
在/etc/systemd/system目录下创建 mysql.service 文件
root下操作
vi /etc/systemd/system/mysql.service
[Unit]
Description=mysql
[Service]
User=mysql
LimitNOFILE=100000
LimitNPROC=100000
ExecStart=/opt/mysql5730/bin/mysqld_safe --defaults-file=/opt/mysql5730/conf/my.cnf
[Install]
WantedBy=multi-user.target
注意如下两个参数不能设置太小,否则mysql会不停重启动
LimitNOFILE=100000
LimitNPROC=100000
设置开机自启
systemctl enable mysql
启动后查看状态
systemctl status mysql
systemctl daemon-reload