2012-08-23 72 views
3

在主从复制中,我们使用mysql数据库在从服务器上复制少数DB。 我在master上创建了一个用户,不幸的是它没有复制到slave服务器上。复制mysql数据库但在主服务器上创建的用户不在副服务器上复制

Replicate_Do_DB:APP1,APP2,MySQL的

用户创建命令:

GRANT SELECT on *.* to 'user1'@'localhost' identified by 'user1'; 

GRANT SELECT on *.* to 'user1'@'%' identified by 'user1'; 

GRANT SELECT on *.* to 'user1'@'10.10.10.10' identified by 'user1'; 

用户帐号上主成功创建,但不复制在从站。

为什么如果mysql数据库在复制中会发生这种情况?

回答

7

嗯。我打算在这里说一下,并说你可能使用基于STATEMENT的复制而不是基于ROW的复制,并且你的MySQL版本是5.1或更高...

你可以告诉你正在运行哪种类型上运行你的奴隶的SQL语句:

select variable_value 
from information_schema.session_variables 
where upper(variable_name) = 'BINLOG_FORMAT'; 

正如你正确识别权限只复制如果mysql schema is included in replication

但是!“疑难杂症”这里是--replicate-do-db选项。如果您使用的是基于语句复制,那么你将需要运行以来的拨款之前指定的MySQL数据库作为默认数据库:

The effects of this option depend on whether statement-based or row-based replication is in use.

Statement-based replication. Tell the slave SQL thread to restrict replication to statements where the default database (that is, the one selected by USE) is db_name.

这就是说试运行:

USE MYSQL; 

GRANT SELECT on *.* to 'user1'@'localhost' identified by 'user1'; 

GRANT SELECT on *.* to 'user1'@'%' identified by 'user1'; 

GRANT SELECT on *.* to 'user1'@'10.10.10.10' identified by 'user1'; 

它可能会奏效。如果它不,然后看另一个答案!

+0

这对我很有用。 Binlog格式为MIXED。 –

+0

很好听,它的工作。你能接受这个答案吗? –

+0

http://dev.mysql.com/doc/refman/5.0/en/replication-features-userprivs.html现在是一个断开的链接 – knocte

0

在MySQL 5.7,如果执行从汤姆Mac的answer查询时,您将收到以下错误:

ERROR 3167 (HY000): The 'INFORMATION_SCHEMA.SESSION_VARIABLES' feature is disabled; see the documentation for 'show_compatibility_56'

您应该查询performance_schema代替。执行以下操作:

SELECT variable_value FROM performance_schema.session_variables WHERE upper(variable_name) = 'BINLOG_FORMAT'; 
相关问题