Main
1.
My.cnf
Server-id = 1
Log-bin=mysql-bin
Read-only=0 #主机, can read and write, 1 only
Binlog-do-db=dbname--The name of the database to synchronize, multiple write multiple lines
Binlog-ignore-db=dbname--Do not synchronize database names, multiple write multiple lines
2.
Restart
Service mysqld Start
3. Create a user
Grant Replication Slave on * * to [e-mail protected] '% ' identified by ' 1234 ';
Flush privileges;
4.
Show master status; Record file:binlog.000016 and position:7333
Cd.
From
1.MY.CNF Server-id = 2
2. See if communication with the main library
Pay: Stop slave;
3.
Change Master to master_host= ' 192.168.1.45 ', master_user= ' repuser ', master_password= ' 1234 ', master_log_file= ' Mysql-bin.000016 ', master_log_pos=9390;
4.
Open start slave;
5. See if the communication
show slave status \g;
As appears
Slave_io_running:yes (Network Normal, if the server is disconnected or no boot);
Slave_sql_running:yes (table structure is normal, if the table structure is not the same, and the data is not the same)
Yes indicates that the synchronization is normal,
Ok
Database Master-Slave (2)