1. 程式人生 > >centos7.x設定mysql自啟動

centos7.x設定mysql自啟動

編譯安裝mysql併成功初始化後

whereis mysql
cd /usr/local/mysql
cp support-files/my-default.cnf /etc/my.cnf

vi /etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000
#新增到開機啟動
systemctl enable mysqld.service
systemctl start mysqld
systemctl stop mysqld
systemctl status mysqld