MySQL configuration master-slave replication

Source: Internet
Author: User

The main record is the process of configuring master-slave replication and issues. Reference link: http://blog.sina.com.cn/s/blog_4c197d4201017qjs.html.

First, MySQL

Local Windows environment, download the free install version, extract two copies to local and modify the port usage number, respectively, 3306, 3307.

Second, the configuration

1.master

(1) Start MySQL service, command line login Mysql:mysql-u root-p

(2) Authorization: Grant REPLICATION SLAVE on * * to ' repl ' @ ' 127.0.0.1 ' identified by ' slaveuser ';

(3) Querying the state of the main library: show master status;

2.slave

(1) Open the MySQL installation directory of My.ini, modify Server-id = 1 for Server-id = 2, note that this ID must be unique

(2) Start MySQL service, command line login Mysql:mysql-u root-p

(3) Execute the synchronization statement:

 to Master_host='127.0.0.1', master_port=3306, Master_user='repl', Master_password=' slaveuser  ',
1master_log_file=' mysql-bin.000031', Master_log_pos=1385 ;

Each of these parameters is set or queried in the previous step 1.

(4) Start slave process: start slave;

After completing the above steps, you can view the log files of the slave.

OK, this configuration is successful.

Some of the issues that you may encounter:

1. Do not perform replication to view the slave error log:

(1) Check if master correctly authorizes REPL users

Main Library command line execution:

There's nothing wrong with that.

(2) Log in to master from the slave command line:

Incorrect password settings, re-executing the synchronization statement on slave and ensuring that the password is correct:

Shutdown slave process information: stop slave;

Perform the synchronization statement in step 2, change ...

Start slave process: start slave;

2. The configuration does not have to be successful at one time, sometimes several times back and forth, when the slave synchronization process is initiated, the command line may report:

    ERROR 1198 (HY000): This operation cannot is performed with a running slave; run STOP slave firSt

At this point, the shutdown must be performed first: stop slave;

MySQL configuration master-slave replication

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.