[Turn]http://blog.csdn.net/lwprain/article/details/10966837
Note: Before the configuration before the master has never been successful, it is best to put the master database directory of mysql-bin.000000x and Mysql-bin.index, and salve under the relay-bin.00000x, Relay-bin.index, Log-bin, etc. deleted, restart service reconfiguration
Synchronize State key statements, each time the main library restarts are performed at slave:
Show master status;
to Master_host='192.168.0.45', master_user='slave_user ', Master_password='root';
The following operations are successful in Winows XP testing in VMware virtual machines
In the middle of a lot of detours, online a lot of information is for 5.1 of the previous version, in the new edition can not be used at all, so according to their own practice to organize this article
Main service: 192.168.131.21
From server: 192.168.131.22
1, the configuration of the host
Configuration in My.ini:
server-id=1 binlog_format="ROW"log-bin=mysql-bin
After starting the service, go to the MySQL command line and do the following:
GRANT All on *. * to ' slave1 '@'192.168.131.22'by '123456 ';
If you need to synchronize a database, it is best to create only the appropriate database permissions, such as:
GRANT All on Test1. * to ' slave1 '@'192.168.131.22'by '123456' ;
This will only synchronize the contents of the database.
2. Setting from server
My.ini:
Server-id=2relay-log-purge=1 Skip -slave-start #此处为不同步mysql数据库的内容此处如果为多数据库的话中间以逗号分开 replicate- Ignore-db=
Then launch MySQL into the command line and execute the following command
to Master_host='192.168.131.21', master_user='slave1 ', master_password='123456';
3, start the master-slave replication
Start the service of the primary server first
Next start the service from the server
Then execute from the server command line
Start slave;
Then execute the following command to view the status from the server
SHOW SLAVE Status\g
Show:
Slave_IO_Running:YesSlave_SQL_Running:Yes must be yes.
It is also important to note that:
I am doing from the server, is to stop the service, and then the overall copy of the data directory, if not made any changes, will appear the following prompt:
[ERROR] Slave I/o: Fatal error:the Slave I/O thread stops because master and Slave have equal MySQL server UUIDs; These uuids must is different for replication to work. error_code:1593
121122 17:40:58 [Note] Slave I/O thread exiting, read up to log ' first ', Position 4
At this point, you should remove the AUTO.CNF from the data directory and restart the service
Execute start slave;
Then create the database on the master server
You can see the synced data from the server again.
And if you change the machine name from the server, you can execute the command like this:
Stop slave;
Reset slave;
Start slave;
Give it a try
MySQL 5.6.x Configuration Database master-slave replication