MySQL master-slave configuration (clear idea)

Source: Internet
Author: User

MySQL master-slave configuration. My humble opinion is tested in the following environment:

Operating system where the primary database resides: Win7

Master Database version: 5.0

IP address of primary database: 192.168.1.111

From the operating system where the database resides: Linux

Version of Master data: 5.0

IP address of primary database: 192.168.1.112

When you're done with the environment, just talk about the configuration steps:

1. Make sure that the primary database is identical to the database.

    For example: The database of a in the main database has a b,c,d table, that from the database should have a mold carved out of a database and B,c,d table

2. Create a sync account on the main database.

    GRANT REPLICATION slave,file on * * to ' mstest ' @ ' 192.168.1.112 ' identified by ' 123456 ';

192.168.1.112: Is the IP address that the user is running with

MSTest: Is the newly created user name

123456: Is the password for the newly created user name

The above command of the detailed explanation, it is best to Baidu, write too much counter to more unclear ideas.

3, configure the primary database My.ini (because it is under window, so is My.ini not my.cnf).

Server-id=1
Log-bin=log
Binlog-do-db=mstest//MSTest database to be synchronized, to synchronize multiple databases, add several replicate-db-db= database names

Binlog-ignore-db=mysql//Database to ignore

4, configure the MY.CNF from the database.
server-id=2
master-host=192.168.1.111
Master-user=mstest//First step create username for account
master-password=123456//First step create password for account
master-port=3306
Master-connect-retry=60
Replicate-do-db=mstest//MSTest database to be synchronized, to synchronize multiple databases, add several replicate-db-db= database names
Replicate-ignore-db=mysql//Database to ignore
5. Verify Success

    Enter MySQL, after input command: show slave status\g. will be displayed. If both slave_io_running and slave_sql_running are yes, then it is possible to synchronize successfully

6, test synchronization data.

Enter the main database Input command: INSERT into one (name) values (' Beijing ');

Then enter the command from the database: SELECT * from one;

If the data is obtained from the database at this time, the synchronization is successful, and the master-slave realizes the

MySQL master-slave configuration (clear idea)

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.