1 MySQL master-slave synchronization, prepare 2 servers, already installed MySQL
Master: mysql1:192.168.12.101
From: mysql2:192.168.12.102
2 master-Slave synchronization requires the Binl-og log to be turned on and the library from MYSQL2 needs to be greater than or equal to the Lord.
Cat/etc/my.cnf
= #值随意, make the expression, the Lord and never the same can log-bin=mas #启bin-log log, you can directly Log-bin
binlog_format= "MM"
Systemctl stop MySQL
Systemctl start MySQL
3 MYSQL1:
Authorized to log in to the account, set the password:
Grant Replication Slave on * * to [email protected]"192.168.12.101""123456 ";
In the MySQL2 test login:
mysql-h192.168.12.101-uuser1-p123456
Show grants;
MYSQL1:
Remember the need on the MYSQL2.
MYSQL2:
Cat/etc/my.cnf
= systemctl stop mysqlsystemctl start MySQL
Mysql> Change Master to
master_host="192.168.12.101", master_user="user1" , Master_password="123456", Master_log_file=" mas.000002 " , Master_log_pos=332; MySQL>show slave status\g;mysql> start slave;mysql >show slave status\g;
To see if the configuration was successful:
When there is no yes, the configuration is successful. No configuration succeeded reading the newspaper wrong
4 Test MYSQL1: Create a library. Table, insert data, check in MYSQL2.
MySQL Master-Slave synchronization