MySQL Master-Slave synchronization

Source: Internet
Author: User
Tags log log

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.