备份
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;