MySQL Master-slave database

Source: Internet
Author: User

reading: MySQL database is a functional not very powerful relational database management system, although the function is not perfect, but MySQL database with speed, adaptability, high reliability advantages to win the favor of the majority of users, see MySQL database performance, You should start from the configuration of MySQL database, the following is a detailed discussion of MySQL database master-slave configuration problem.

Server-id one can be set by itself, but try not to set it to 1, nor can it be duplicated from the server.
Requires two hosts, respectively, as primary and slave servers

Primary server ip:192.168.1.1

From server ip:192.168.1.2

First, the MySQL service is configured on two services respectively.

On the primary server:

# VIM/ETC/MY.CNF

Modify or add the following entries

Log-bin=master-bin

Log-bin-index=master-bin.index

server-id=11

Note: Server-id can be set on its own, but try not to set it to 1 or repeat it from the server.

Restart Service

# Service Mysqld Restart

Add replication (copy) account number: REPL

# MySQL

>grant REPLICATION SLAVE,

>replication CLIENT On * *

>to [email protected] ' 192.168.1.% '

>identified by ' Redhat ';

Note: * * represents any table in any database, ' 192.168.1.% ' indicates that only the primary high Access database for 192.168.1.0 network segments is allowed

>flush privileges;

>\q

On the from server side:

# VIM/ETC/MY.CNF

Modify or add the following entries:

Relay-log=relay-log-bin

Relay-log-index=slave-relay-bin.index

Server-id=22

Note: Server-id cannot be the same as the primary server

Restart MySQL Service

# Service Mysqld Restart

# MySQL

>change MASTER to

>master_host= ' 192.168.1.1 ', # #主服务器的IP

>master_port=3306, # #3306不能加引号, this trip is dispensable

>master_user= ' Repl ',

>master_password= ' redaht ';

>

>start SLAVE;

To this, the master-slave MySQL server configuration is complete!

Test:

Modify the database on the primary server, such as:

# MySQL

>creat DATABASE MyDB;

Viewing from the server side:

# MySQL

>show DATABASES;

There will also be an identical database named MyDB!

About MySQL database of the master and slave configuration of knowledge for everyone to introduce so much, I hope that we can have something to gain

-----Excerpt from Http://database.51cto.com/art/201104/255282.htm

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.