For practitioners in every IT industry, whether developers, project managers, or testers, understanding the actual operations of the MySQL Database Synchronization instance will make our actual operations easier and easier. The following is a detailed description of the MySQL Database Synchronization instance.
This experiment is used to configure the master-slave MySQL Database Synchronization for the MySQL database (the best combination with PHP). I will not talk about it much and start the specific configuration.
In this test, MySQL (the best combination with PHP) versions are 4.1.7-standard-log, the master operating system is redhat 9.0, And the slave operating system is redhat 7.3.
1. modify my. cnf on the master end and add the configuration parameters:
[MySQL (the best combination with PHP) d]
- log-bin
- server-id=1
2. modify my. cnf on the slave side and add the configuration parameters:
- log-bin
- mastermaster-host=master
- master-user=rep
- master-password=rep
- master-port=3306
- server-id=2
The above parameters are the most basic configuration, so I will not explain them much. I will undo it to initialize the data.
1. Clear all binlogs on the master. If the existing binlogs are useful, back up them first. Then, pack all data files on the master, including ibdata files.
2. A similar method is used to clear all binlogs on the slave and copy the data file compressed package on the master to its own data file directory.
Start the master and add a rep user ,"
- grant all privileges on *.* to rep@% identified by 'rep'; flush privileges; ".
Start slave and check whether MySQL Database Synchronization is successful.
Generally, the reason for the failure is that the binlog fails to be located after the slave connects to the master. Therefore, you need to set the binlogs of both parties to be consistent, and then stop slave; start slave.