Mysql master-slave configuration, mysql master-slave Configuration
There can be many slave databases. We assume one master M and one slave S.
Add the master M configuration file:
Server-id = 1
Bin-log = logbin
This name is random
Remember to restart
Add from S configuration file:
Server-id = 2
The configuration file is complete.
Run the following command on the master M client:
> Show master status;
File and Position, for example, logbin.000001 120
Run the following command on the slave S client:
> Change master to master_host = 'master address of master s', master_user = 'account with synchronization and replication authorization', master_password = 'Password', master_log_file = 'logbin. 000001 ', master_log_pos = 120;
Synchronization REPLICATION permission refers to replication slave.
Example SQL:
> Grant replication slave on *. * to 'user' @ 'localhost' identified by 'pwd ';
> Flush privileges;
Enable slave S:
> Start slave;
View slave S status:
> Show processlist;
Complete.
Master-slave backup is the command automatically executed by the master M machine on the slave S machine, so if M already has a database that S does not have, your operations on the database will cause synchronization replication to fail. Therefore, we recommend that you use a clean mysql instance for backup.
Stop slave backup in slave S: stop slave; clear: reset slave;