主库配置
server-id = 1 log-bin = mysql-log-bin read-only = 0 binlog-do-db = testdb 要同步的数据库 #binlog-ignore-db = mysql,information_schema 不要同步的和上面的设置一个即可
通过show master status 可以查看配置
主库上备份的用户
grant replication slave on *.* to ‘用户名’@'主机’ identified by ‘密码’;
从库配置
server-id = 2 replicate-do-db = testdb 要同步的数据库
change master to master_host='主库IP',master_user='backup',master_password='root';
slave start
show slave status 查看状态
slave stop 停止同步