I did this on MySQL 5. I wanted my laptop db to replicate to my server as a backup mechanism.html
server-id = 1 log_bin = /var/log/mysql/mysql-bin.log expire_logs_days = 10 max_binlog_size = 100M # multiple dbs binlog_do_db = test binlog_do_db = foobar
GRANT REPLICATION SLAVE ON *.* TO 'testuser'@'%' IDENTIFIED BY 'testuser';
mysql
server-id=2 master-host=192.168.19.41 master-user=testuser master-password=mypassword master-connect-retry=60 # multiple dbs replicate-do-db=test replicate-do-db=foobar
tail -f /var/log/mysqld.log 080813 20:42:02 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000107', position 110879 080813 20:42:02 [Note] Error reading relay log event: slave SQL thread was killed 080813 20:44:17 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000107' at position 110879, relay log './mysqld-relay-bin.000003' position: 109924 080813 20:44:22 [Note] Slave I/O thread: connected to master 'testuser@192.168.19.44:3306', replication started in log 'mysql-bin.000107' at position 110879
If you see an error in the slave log, like this: sql
080813 21:57:52 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000107' position 111555or in the Last Error column of SHOW SLAVE STATUS, you will need to skip query and restart the slave. On the Slave, run: SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;SLAVE START; Of course, what you need to really find out is why the error occurred. Make sure that:
Also, consider row-based replication, which is not based on the SQL statement run, but rather the value of the rows in the table.ide
Back to Codethis