For more information about Mysql master-slave server configuration in Windows, see this article.
For more information about Mysql master-slave server configuration in Windows, see this article.
The configuration steps are as follows:
1. mysql configuration file my. cnf location
2. how to start and stop mysql and find the startup file
Suppose there are two machines and mysql has been installed (try to use the same version, and the two machines have the same network, you can ping)
A friend said, "the slave server cannot be lower than the master server version." However, I am lower than the master server version and there is no problem.
Host A: 192.168.1.100
Slave B: 192.168.1.101
Multiple slave servers
1. log on to host A first.
Mysql> grant replication slave on *. * TO 'backup '@ '192. 168.1.101 'identified BY '123 ';
Grant permissions to the slave machine. if multiple slave machines exist, the slave machine is executed multiple times.
2. open my. cnf of host A and enter
| The code is as follows: |
|
|
Server-id = 1 # host id, integer
Log_bin =/var/log/mysql/mysql-bin.log # make sure this file is writable
Read-only = 0 # host, both read and write are allowed
Binlog-do-db = test # you need to back up data and write multiple rows.
Binlog-ignore-db = mysql # databases that do not need to be backed up, multiple write lines |
3. open my. cnf of slave Machine B and enter
| The code is as follows: |
|
|
Server-id = 2
Log_bin =/var/log/mysql/mysql-bin.log
Master-host = 192.168.1.100
Master-user = backup
Master-pass = 123456
Master-port = 3306
Master-connect-retry = 60 # time difference (in seconds) when the master server is disconnected from the server)
Replicate-do-db = test # Only Copy a database
Replicate-ignore-db = mysql # Do not copy a database |
4. synchronize databases
There are multiple ways to export the data test of host A to test. SQL first.
Then, create the database test from Machine B. mysql imports test. SQL to the database test.
5. restart mysql of host A and mysql of slave B.
6. verification
| The code is as follows: |
|
|
In Host A, mysql> show master statusG;
In slave Machine B, mysql> show slave statusG; |
You can see the following content:
| The code is as follows: |
|
|
File: mysql-bin.000001
Position: 1374
Binlog_Do_DB: test
Binlog_Ignore_DB: mysql |
You can perform INSERT, UPDATE, and DELETE operations in host A to check whether the operation has been modified in host B.