mysql主从配置

开启mysql只读模式:

FLUSH TABLES WITH READ LOCK;
SET GLOBAL read_only = 1;

查看主数据库状态:
show master status; //可以查看主mysql状态

备份主数据库:

mysqldump -h -ujbbwbu -p jbbwb > jbbwb.sql

导入备份文件到从数据库:

source jbbwb.sql

设置同步点:
change master to
-> master_host=’192.168.78.128′,
-> master_user=’test’,
-> master_password=’MyPass1!’,
-> master_log_file=’mysql-bin.000001′,
-> master_log_pos=1244;

start slave;

show slave status \G;

关闭mysql只读模式:
SET GLOBAL read_only = 0;
UNLOCK TABLES;

发表评论

电子邮件地址不会被公开。 必填项已用*标注