MySQL5.7 master-slave configuration instance resolution, mysql5.7 master-slave instance

Source: Internet
Author: User

MySQL5.7 master-slave configuration instance resolution, mysql5.7 master-slave instance

MySQL5.7 master-slave configuration implementation method, the specific content is as follows

Installation environment:

Master: 10.211.55.11, Redhat6.5, MySQL5.7.12
Slave: 10.211.55.12, Redhat6.5, MySQL5.7.12

Master's my. cnf Configuration:

My. cnf configuration of Slave:

You can specify the databases that need to be copied and those that do not need to be copied. For example, all the contents commented out in my. cnf configuration are copied by default. After modifying the my. cnf configuration file, both machines restart the MySQL service: service mysqld restart. The following operations are important:
Mysql configuration on the Master machine

1. log on to mysql-u root-p;
2. Execute the following command to grant the root copy and File permissions of 10.211.55.12. Of course, you must create another user to operate the command, not necessarily root. 123456 indicates the password.

GRANT FILE ON *.* TO 'root'@'10.211.55.12' IDENTIFIED BY '123456';GRANT REPLICATION SLAVE ON *.* TO 'root'@'10.211.55.12' IDENTIFIED BY '123456';FLUSH PRIVILEGES;

3. Execute the show master status Command,

Mysql configuration of the Slave machine

1. log on to mysql-u root-p;
2. Execute the following commands in sequence:

mysql> stop slave;mysql> change master to master_host='10.211.55.11',master_user='root',master_password='123456',master_log_file='mysql-bin.000003', master_log_pos=154;mysql> start slave;

Note:
The values in master_log_file and master_log_pos must correspond to the values in the result (for example) of the show Master status of the master machine.

3. Check the salve status. show slave status \ G. Note that the "\ G" here is to display the formatted result. If there is no error, the slave status result is as follows:

Test:

Create a database in the Master:

mysql> create database test;mysql> create table t1 (id int,name varchar(200),createtime timestamp,key(id));mysql> insert into t1 values (1,'aa',now());mysql> insert into t1 values (3,'bb',now());

After performing the preceding operations, switch to the Salve machine to see if the synchronization was successful. If not, it should be synchronized immediately.
My machine is shown as follows:

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.