如何实现两台服务器mysql数据库同步

如题所述

1.主上修改my.cnf文件:
server-id=1
log-bin=mysql-bin
2.从上修改配置文件 my.cnf
server-id=2
relay-log=relay-bin
read-only =1
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
#replicate-wild-do-table = tt.admin
replicate-wild-do-table = my_db.stu // 所要同步的数据库的单个表
3. 创建 同步的用户(主上)
grant replication client,replication slave on *.* to rep@'10.41.50.105' identified by 'root';

4.同步到主库(在从上操作)
change master to master_host='10.41.50.80',master_user='rep',master_password='root';
5.在从上验证:
show slave status\G;

主从同步某些表
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜