关于mysql:MySQL-单机多实例安装基于mysqldmulti

49次阅读

共计 1235 个字符,预计需要花费 4 分钟才能阅读完成。

1、更新 my.cnf 配置文件

1.cat /etc/mysql/my.cnf
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld_safe
mysqladmin=/usr/local/mysql/bin/mysqladmin
Log=/usr/local/mysql/logs/multi.log

[mysqld1]
datadir=/usr/local/mysql/data1
socket=/usr/local/mysql/run/mysql.sock3307
pid-file=/usr/local/mysql/run/mysql1.pid
port=3307

[mysqld2]
datadir=/usr/local/mysql/data2
socket=/usr/local/mysql/run/mysql.sock3308
pid-file=/usr/local/mysql/run/mysql2.pid
port=3308

[mysqld3]
datadir=/usr/local/mysql/data3
socket=/usr/local/mysql/run/mysql.sock3309
pid-file=/usr/local/mysql/run/mysql3.pid
port=3309

2、初始化 mysqld(记录每个实例产生的随机明码)

bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data1 --user=mysql --initialize
bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data2 --user=mysql --initialize
bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data3 --user=mysql --initialize

3、启动多实例

mysqld_multi report
mysqld_multi start 1
mysqld_multi start 2
mysqld_multi start 3

4、别离连贯每个实例,而后批改明码

mysql -u root -S /usr/local/mysql/run/mysql.sock3307 -p
mysql -u root -S /usr/local/mysql/run/mysql.sock3308 -p
mysql -u root -S /usr/local/mysql/run/mysql.sock3309 -p

5、增加开机自启动 mysqld_multi

cp support-files/mysqld_multi.server /etc/init.d/mysqld_multi
chkconfig --add mysqld_multi
chkconfig --list | grep mysql

正文完
 0