当前位置:Gxlcms > 数据库问题 > mysql5.7.21 主存复制

mysql5.7.21 主存复制

时间:2021-07-01 10:21:17 帮助过:4人阅读

备份

PlUSH TABLES WITH READ LOCK;
mysqldump -u username -p --databases dbname2 dbname2 > weshop_test.sql
UNLOCK TABLES

恢复 mysql -uroot -p -h 127.0.0.1 -P23306  weshop_test <weishop_test.sql


master

[mysqld]

log_bin=master-bin
log_bin_index = master-bin.index
server-id=1
binlog_do_db=weshop_test
binlog_ignore_db = mysql
expire-logs-days=7

执行:

grant replication slave on *.* to ‘slave1‘ @‘%‘ identified by ‘123456‘;
show master status;

slave

[mysqld]
server-id=2
relay-log = slave-relay-bin
relay-log-index = slave-relay-bin.index

执行:

change master to master_host=‘master‘,master_port=3306,master_user=‘slave1‘,master_password=‘123456‘,master_log_file=‘master-bin.000002‘,master_log_pos=154
show satus status;

mysql5.7.21 主存复制

标签:databases   mysq   cat   mysqldump   恢复   dbn   master   day   备份   

人气教程排行