First, master-slave replication works
The process by which MySQL implements the entire replication between master and slave is done by 3 threads, of which two threads (SQL thread and IO thread) are on the slave side, and another thread (IO thread) on the master side
Note: To achieve MySQL replication you must first open the binary log (that is, the binary log) on the master side, otherwise you will not be able to implement
The basic process for MySQL replication is as follows:
(1) Slave The above IO thread initiates the connection and requests the location of the specified log file
(2) master receives a request from the Slaveio thread and returns this information to Slave's IO thread (return information) by specifying the location of the log based on the requested information, using the IO thread responsible for the replication (i.e. the Masterio thread).
(3) After the slave IO thread receives the return information from the master side, the log contents are written to the slave side relay Log file (mysql-relay-bin.xxx), and read the Bin-log file and location on the master side, recorded in the Master=info file, so that the next time you can clearly tell master from where to start transmitting bin-log content
(4) Slave SQL thread detection: Relay log Add content, immediately parse the contents of the master binary file, and execute the inside of the query statement
Second, the specific operation
(1) operation on master first the Bin-log log is opened and then Server-id set to 1 will log-slave-updates to shut down establish an internal replication communication user grant replication Slave on *. * to ' Admin ' @ ' 10.0.0.202 ' identified by ' 123456 '; flush privileges; (2) Operation on slave first Bin-log log is turned on next Server-id set to 2 will log-slave-updates open >stop Slave;>change master to master_host= ' 10.0.0.201 ', master_user= ' admin ', master_password= ' 123456 ', master_log_file= ' mysql-bin.000005 ', master_log_pos=578 ; >start slave;>show slave status\g;