Example linux binary installation plurality mysql

Mysql first download the source package, Quguan network to find the version you want to install, download it, install it now is mysql 5.6, the new directory in a package of home, the download command.

wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz

unzip files

tar -zxvf  mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz

Add mysql user and mysql user group

 
groupadd mysql
useradd -r -g mysql -s /bin/false mysql

Install mysql library needed

yum install libaio 

Create a directory to install mysql

cd /usr/local/;
 
mkdir mysql3307;
 
mkdir mysql3308;

Mysql3307 source and copied to directory mysql3308

cp /home/package/mysql-5.6.42-linux-glibc2.12-x86_64 /usr/local/mysql3307 -R
cp /home/package/mysql-5.6.42-linux-glibc2.12-x86_64 /usr/local/mysql3308 -R 

Jump down mysql3307 directory execute [mysql using mysql --user specifies the user to run, - fefaults-file is specified mysql configuration file to prevent multiple instances of the conflict]

scripts/mysql_install_db --user=mysql --defaults-file=/usr/local/mysql3307/my.cnf

Jump mysql3308 directory under execution

scripts/mysql_install_db --user=mysql --defaults-file=/usr/local/mysql3308/my.cnf

And confirm whether mysql3307 generate the corresponding my.cnf file mysql3308

ll /usr/local/mysql3307/my.cnf
ll /usr/local/mysql3307/my.cnf

Modify the corresponding configuration file

vim /usr/local/mysql3307/my.cnf
 
修改对应的目录
 15 basedir = /usr/local/mysql3307
 16 datadir = /usr/local/mysql3307/data/
 17 port = 3307
 18 server_id = 3
 19 socket =/tmp/mysql.sock 
 
vim /usr/local/mysql3308/my.cnf
 
修改对应的目录
 15 basedir = /usr/local/mysql3308
 16 datadir = /usr/local/mysql3308/data/
 17 port = 3308
 18 server_id = 3
 19 socket =/tmp/mysql3308.sock   # 连接文件区分一下

Start mysql instance:

/usr/local/mysql3307/bin/mysqld_safe &
/usr/local/mysql3308/bin/mysqld_safe &

View the process, if successful start

ps -ef | grep mysql

Testing database connection

# -h 127.0.0.1不能省去,防止直接通过mysql.sock文件进行连接
# 进入mysql3307
 mysql -uroot -p -h 127.0.0.1 -P3307
 
进入mysql创建测试库
 create database db3307
 
进入mysql3308
 mysql -uroot -p -h 127.0.0.1 -P3308
 
进入mysql创建测试库
 create database db3308
 
进入对应数据库,看是否正确

 

Guess you like

Origin blog.csdn.net/lr199966/article/details/90715310