一、上传软件并解压、创建软连接
[root@db01 app]# ln -s mysql-5.6.46-linux-glibc2.12-x86_64 mysql56
[root@db01 app]# ln -s mysql-8.0.18-linux-glibc2.12-x86_64 mysql80
二、配置文件重命名
[root@db01 app]# mv /etc/my.cnf /etc/my.cnf.bak
三、注释环境变量
[root@db01 app]# cat /etc/profile
#export PATH=/data/app/mysql/bin:$PATH
四、生效环境变量并检查
[root@db01 app]# source /etc/profile
[root@db01 app]# mysql -V
-bash: /usr/bin/mysql: No such file or directory
五、准备5.6和8.0数据库目录
[root@db01 app]# mkdir -p /data/3316/data /data/3326/data
六、初始化数据
5.6初始化
/data/app/mysql56/scripts/mysql_install_db --user=mysql --basedir=/data/app/mysql56 --datadir=/data/3316/data
8.0初始化
/data/app/mysql80/bin/mysqld --initialize-insecure --user=mysql --basedir=/data/app/mysql80 --datadir=/data/3326/data
七、授权
[root@db01 ~]# chown -R mysql. /data/*
八、准备配置文件
[root@db1 ~]# cat /data/3316/my.cnf
[mysqld]
user=mysql
basedir=/data/app/mysql
datadir=/data/3316/data
socket=/tmp/mysql3356.sock
port=3316
server_id=16
[root@db1 ~]# cat /data/3326/my.cnf
[mysqld]
user=mysql
basedir=/data/app/mysql80
datadir=/data/3326/data
socket=/tmp/mysql80.sock
port=3326
server_id=26
九、编写配置脚本
[root@db1 ~]# cat /etc/systemd/system/mysql3316.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=/data/app/mysql56/bin/mysqld --defaults-file=/data/3316/my.cnf
LimitNOFILE = 5000
[root@db1 ~]# cat /etc/systemd/system/mysqld3326.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=/data/app/mysql80/bin/mysqld --defaults-file=/data/3326/my.cnf
LimitNOFILE = 5000
十、恢复环境变量
[root@db1 ~]# cat /etc/profile
export PATH=/data/app/mysql/bin:$PATH