I have two servers server1 and server2 that I've setup a master-master replication
But on server1 I have a lot of databases and on server2 I have only one that is the database I want to replicate with server1
I've setup the replication and it was working fine but after someone started altering some other database on server1 and I started getting these errors on server2 replication
"Error 'Table 'database.table' doesn't exist' on query. Default database: ''"
I think it's because server2 only has the database I want to sync
Here is the my.cnf configuration on Server2
Server2
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 200M
binlog_do_db = databaseiwanttosync
binlog-checksum = none
binlog_ignore_db = information_schema,mysql,performance_schema
auto_increment_increment= 2
auto_increment_offset = 1
Server1
server-id = 2
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 200M
binlog_do_db = databaseiwanttosync
#binlog-checksum = none
binlog_ignore_db = information_schema,mysql,performance_schema,phpmyadmin
auto_increment_increment= 2
auto_increment_offset = 2
Use --replicate-do-db=db_name
Tell the slave SQL thread to restrict replication to statements where the default database (that is, the one selected by USE) is db_name. To specify more than one database, use this option multiple times, once for each database; however, doing so does not replicate cross-database statements such as UPDATE some_db.some_table SET foo='bar' while a different database (or no database) is selected.
Source: http://dev.mysql.com/doc/refman/5.6/en/replication-options-slave.html#option_mysqld_replicate-do-db
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.