Pre-conditions:
A host (as the primary server)
Environment: win7,mysql5.5 ip:172.17.42.82
b Host (as Slave server)
Environment: win7,mysql5.5 ip:172.17.42.156
Primary server configuration:
1. Create a sync dedicated account in MySQL database a slave
Command: GRANT REPLICATION slave,reload,super on * * to [e-mail protected] ' 172.17.42.156 ' identified by ' 517na.com ';
Note: 172.17.42.156 is the password for the account 517na.com from the server's IP slave
2. Modify the A server configuration to open the Mysql/my.ini file, add the following under [Mysqld]:
server-id=10 Log-bin=mysql-bin
Where: Server-id: ID value for primary Server A (recommendation 1-32, preferably after 10)
Log-bin: Binary Change Day value
3. Restart a server (from now on, it will record the client-related database changes in the binary change log)
Command:
net stop MySQL
net start MySQL
From the server configuration:
1. Modify the B server configuration to open the Mysql/my.ini file, add the following under [Mysqld]:
server-id=11
Log-bin=mysql-bin
Relay-log=relay-bin
Relay-log-index=relay-bin-index
Replicate-do-db=songyustock
Note: replicate-do-db: Databases that need to be synchronized
2. Restart the B server
3. Log in to MySQL and enter the following command:
Stop slave;
Master_host= ' 172.17.42.82 ', master_user= ' slave ', master_password= ' 517na.com ';
Start slave;
4. Check that the settings are correct
Command: show slave status\g;
The main is to see if the following two items are yes:
Slave_io_running:yes
Slave_sql_running:yes
Note:
1. View sever_id's command: Show Varias like ' server_id ';
2. Reference article: http://blog.csdn.net/g2321514568/article/details/12441049
Common errors in configuration:
1.ERROR (HY000): The server is not configured as slave; Fix in config file or with change MASTER to
Solution: http://bg.artuion.com/window_linux/122.html
2.MySQL Synchronous Failure: Two solutions for "Slave_sql_running:no"
Solution: Http://blog.chinaunix.net/uid-21505614-id-289477.html http://kerry.blog.51cto.com/172631/277414
3.linux under Configuration Master-slave reference article: http://www.cnblogs.com/cchun/p/3712637.html
mysql5.5 Master-Slave synchronization under Windows