1:准备多个目录

  mkdir -p /data/330{7,8,9}/data

2: 准备多个配置文件

[mysqld]

basedir=/application/mysql

datadir=/data/3307/data

socket=/data/3307/mysql.sock

log_err=/data/3307/mysql.log

port=3307

server_id=7

log_bin=data/3307/mysql-bin

3: 初始化数据

  mv /etc/my.cnf /etc/my.cnf.bak

  mysqld --initialize-insecure --user=mysql --basedir=/application/mysql5.7.28 --datadir=/data/3307/data --lc_messages=en_US

  mysqld --initialize-insecure --user=mysql --basedir=/application/mysql5.7.28 --datadir=/data/3308/data --lc_messages=en_US

  mysqld --initialize-insecure --user=mysql --basedir=/application/mysql5.7.28 --datadir=/data/3309/data --lc_messages=en_US

4: 编辑启动文件

  cd /etc/systemd/system

  cp mysql.service mysqld3307.server

  cp mysql.service mysqld3308.server

  cp mysql.service mysqld3309.server

  # 三个文件都需要修改各自的配置文件

  vim mysqld3307.server

  ExecStart=/application/mysql5.7.28/bin/mysqld --defaults-file=/data/3307/my.cnf

5:授权

  chown -R mysql.mysql /data/*

6:启动

  systemctl start mysqld3307.server

  systemctl start mysqld3308.server

  systemctl start mysqld 3309.server