在同一个服务器上面安装多个MySQL服务,甚至是安装多个不同版本(比如5.7和5.7、5.7和8.0.12),关键在于区分安装目录、数据目录和使用端口等。
可以下面步骤
- 安装MySQL1
wget https://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.22-macos10.13-x86_64.tar.gz
tar -xzvf mysql-5.7.22-macos10.13-x86_64.tar.gz
mv mysql-5.7.22-macos10.13-x86_64 ../mysql5.7.22
cd ../mysql5.7.22/
mkdir data
cd data
mkdir binlog data innodb tmp
cd ../
vi my5.cnf
bin/mysqld --defaults-file=/Users/liwenjie01/mysql5.7.22/my5.cnf --initialize-insecure --user=liwenjie01 --basedir=/Users/liwenjie01/mysql5.7.22 --datadir=/Users/liwenjie01/mysql5.7.22/data/data
bin/mysqld_safe --defaults-file=/Users/liwenjie01/mysql5.7.22/my5.cnf --user=liwenjie01 &
bin/mysql -S /Users/liwenjie01/mysql5.7.22/data/mysql5.sock -uroot -p
create user mysql@"%" identified by "mysql";
grant all privileges on *.* to mysql@"%" with grant option;
flush privileges;
bin/mysql -S /Users/liwenjie01/mysql5.7.22/data/mysql5.sock -umysql -pmysql
- 第二个MySQL服务
安装第二个MySQL步骤和第一个几乎一样:
wget https://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.22-macos10.13-x86_64.tar.gz
tar -xzvf mysql-5.7.22-macos10.13-x86_64.tar.gz
mv mysql-5.7.22-macos10.13-x86_64 ../mysql5.7.22_2
cd ../mysql5.7.22_2/
mkdir data
cd data
mkdir binlog data innodb tmp
cd ../
vi my5.cnf
bin/mysqld --defaults-file=/Users/liwenjie01/mysql5.7.22_2/my5.cnf --initialize-insecure --user=liwenjie01 --basedir=/Users/liwenjie01/mysql5.7.22_2 --datadir=/Users/liwenjie01/mysql5.7.22_2/data/data
bin/mysqld_safe --defaults-file=/Users/liwenjie01/mysql5.7.22_2/my5.cnf --user=liwenjie01 &
bin/mysql -S /Users/liwenjie01/mysql5.7.22_2/data/mysql5.sock -uroot -p
create user mysql@"%" identified by "mysql";
grant all privileges on *.* to mysql@"%" with grant option;
flush privileges;
bin/mysql -S /Users/liwenjie01/mysql5.7.22_2/data/mysql5.sock -umysql -pmysql