replicate-do-db=test2 #同步的数据库
replicate-do-db=test3 #同步的数据库
第三步:
将A的mysql数据的权限给B
mysql>GRANT FILE ON *.* TO 'use101'@'192.168.0.102'IDENTIFIEDBY 'pwd101';
将B的Mysql数据的权限给B操作同上。
第四步:
重启AB数据库,后:
B机器:
mysql>slave start;
查看同步配置情况
A机器:
mysql>show master statusG;
B机器:
mysql>show slave statusG;
假如A与B数据库没有同步,检查mysql安装目录下的.err文件。
如果slave日志中报错信息如下:
060807 11:40:17 [ERROR] While trying to obtain the list of slaves from the master 'xxx.xxx.xxx:3306' user 'rep' got the following error: 'Access denied. You need the REPLICATION SLAVE privilegefor this operation'在master上,执行以下语句查看权限:
mysql>SHOW GRANT FOR 'use101'@'192.168.0.102'G *************************** 1. row *************************** Grants for rep@192.168.0.102: GRANT Select REPLICATION SLAVE ON *.* TO 'rep'@'192.168.0.102'IDENTIFIED BY PASSWORD 'xxx'已经授予了 REPLICAION SLAVE 权限了,怎么还会报这个错呢?
通过查看手册和源码,才知道slave需要执行一个语句来更新slave列表:
SHOW SLAVE HOSTS;而执行这个语句则需要 REPLICAITON CLIENT 权限,因此才会报错。因此,只要重新给 帐号加上 REPLICATION CLIENT 权限就可以了。
grant selectreplication slaveREPLICAION CLIENT on *.* to 'use101'@'192.168.0.102'identified by 'pwd101';









