mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/data/
systemd
注意:sysv方式启动过的话,需要先提前关闭,才能用以下方式启动
[root@docker01 ~]# service mysqld stop
Shutting down MySQL.. SUCCESS!
cat >/etc/systemd/system/mysqld.service<<EOF
[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
EOF
[root@docker01 ~]# cat >/etc/my.cnf <<EOF
[mysqld]
user=mysql
basedir=/usr/local/mysql/
datadir=/data/mysql/data/
socket=/tmp/mysql.sock
server_id=6
port=3306
[mysqld]
socket=/tmp/mysql.sock
EOF