The main purpose of this experiment is to analyze the actual operation steps for configuring master-slave MySQL database synchronization for MySQL (the best combination with PHP) databases, the information I saw on the relevant website two days ago is quite good. I will share it with you 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 (best combination with PHP)]
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 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.
The above content is an introduction to the MySQL database synchronization instance. I hope you will have some gains.