1: Two MySQL servers are required, such as:
master:192.168.1.120
slave:192.168.1.121
Make sure that the MySQL version is the same, you can log in to the MySQL CLI interface and enter:
Select version ();
The MySQL version of this experiment is 5.6
2: To authorize the primary server from the server, log in to Master's MySQL CLI and enter:
Grant all on * * to "test" @ "%" identified by ' 123456 ';
3: Configure the master-slave server bin-log log, add one more server_id=1 in the my.cnf file,
Note: The server_id of the master-slave server is not the same, and if the database version is above 5.5, and your slave server is copied from the master server, please
/USR/LOCAL/MYSQL/AUTO.CNF and/USR/LOCAL/MYSQL/DATA/AUTO.CNF
To delete, or there will be MySQL server_uuid duplication, and can not synchronize the data on the main database, if it is 5.5 before, as long as the guarantee server_id is different on the line
4: Enter from the service MySQL CLI, enter:
Change Master to
Master_host= ' 192.168.1.120 ',
master_user= ' Test ',
master_password= ' 123456 ';
You can enter:
show slave status\g;
See the configuration parameters and synchronization of some errors, more configuration please refer to here to configure (if not \g will show a lump of things),
Then turn on sync:
Start slave;
5: The test is successful, log in to the master server's MySQL CLI interface, enter:
Use test;
CREATE TABLE T1 (
ID Int (10)
);
Show tables;
A new data table is successfully created on the master server, and then you are logged on to the slave server to see if the master is synchronized.
In the MySQL CLI interface from the server, enter:
Use test;
Show tables;
Look at this time is not more than a T1 data sheet, if there is, congratulations, master and slave configuration is successful, otherwise the configuration fails, you can view the error log analysis.
MySQL Master-Slave data synchronization configuration