MySQL Master-Slave backup

Source: Internet
Author: User

MySQL master-slave backup, listen to a noun is very tall, in fact, is the original implementation of MySQL, you only need a simple configuration can be achieved.

The first step: Keep the master-slave two database is synchronous, preferably manually synchronized ;

The second step: Stop two databases, change the configuration file respectively;

Below I use the following two addresses to illustrate the configuration process.

    • Main database: 192.168.0.244
    • From database: 192.168.0.8

master server database, add the following configuration:

Server-id = 244 #这个唯一就OK, usually take the IP address of the following several
Log-bin = E:\mysql\data\mysql-bin #日志所在目录
binlog-do-db = Test #这个是要同步的数据库

From the server database, add the following configuration:

Server-id = 8 #这个唯一就OK, usually take the IP address of the following several
replicate-do-db = Test #这个是要同步的数据库

The third step, restart the MySQL service of two servers respectively;

    • net stop MySQL;
    • net start MySQL;

Two server MySQL service to start up;

The fourth step, the master server authorized slave rights account

GRANT REPLICATION  on *. *  to ' BU '@ '%' by'123456';

Fifth step, log in to the master server, query the master State;

Show master status;

Notice the result, the result inside the thing, in the next will use.

Sixth step: Log in from the server, configure the slave from the server

 to Master_host='192.168.0.244', master_user='  Bu', Master_password='123456', Master_log_file  ='mysql-bin.000004', master_log_pos=516 ;

Master_log_pos is the above query position 516.

Seventh step, start the slave from the server

Start slave;

Eighth step, verify the Slave service status from the server

Show Slave Status\g

The following two states must be yes.

Slave_io_running:yes//This status must be Yes
Slave_sql_running:yes//This status must be Yes

If there is an item for no, it will not be synchronized successfully.

I've met slave_io_running for connecting. That could be the connection above change master to Master_host ... I wrote it wrong.

Nineth step, arbitrarily modify the data of the main database, from the server database immediately updated

MySQL Master-Slave backup

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.