Mysql install multiple instances

Previous article-Mysql stand-alone version installation

Article Directory

Multi-instance installation

In the past, some very low methods were to decompress the two mysqls and put them in different folders. In fact, the multi-instance installation has been considered in mysql. There is also support for corresponding script commands.
Now it is required to install two mysql and one 3307, 3308
create a new /etc/my.cnf configuration as follows

[mysqld]
sql_mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"

[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
log = /var/log/mysqld_multi.log
user=root
pass=root1234%

[mysqld1]
server-id = 11
socket = /tmp/mysql.sock1
port = 3307
datadir =/data1
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
skip_name_resolve = 1
log_error = error.log
pid-file = /data1/mysql.pid1

[mysqld2]
server-id = 12
socket = /tmp/mysql.sock2
port = 3308
datadir = /data2
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
skip_name_resolve = 1
log_error = error.log
pid-file = /data2/mysql.pid2

Create 2 data directories

mkdir /data1 
mkdir /data2

Grant permissions

chown mysql.mysql /data{
    
    1..2}
mysqld --initialize --user=mysql --datadir=/data1 
mysqld --initialize --user=mysql --datadir=/data2
cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multid

Configure boot-up

chkconfig mysqld_multid on

Check status

mysqld_multi report

Insert picture description here
At this time, I found that the perl environment is still needed, install

yum -y install perl perl-devel

It is running and found that there are already instances
Insert picture description here

mysqld_multi start

Start, change the password separately, allow remote connection

mysql -u root -S /tmp/mysql.sock1 -p -P3307 
mysql -u root -S /tmp/mysql.sock2 -p -P3308
set password = 'root1234%'; 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root1234%'; 
flush privileges;

Guess you like

Origin blog.csdn.net/weixin_42292697/article/details/114014553