在同一個服務器上面安裝多個MySQL服務,甚至是安裝多個不一樣版本(好比5.7和5.七、5.7和8.0.12),關鍵在於區分安裝目錄、數據目錄和使用端口等。mysql
能夠下面步驟sql
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步驟和第一個幾乎同樣:shell
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