MySQL master-slave database configuration

Source: Internet
Author: User

First set up the MySQL master server:

To create a user from the server on the primary server:

1.grant replication Slave on *.* to 192.168.0.1 identified by ' 1234 ';

#4.1 with this, before you can use file.

#grant file on *.* to 192.168.0.1 identified by ' 1234 ';

#后来我又加了super和client Save permission, you can not add it first. and then try again.

Configuration file:/etc/my.cnf

2. On the primary server

Server-id = 1

Log-bin

binlog-do-db= the name of the database you want to back up, and if you back up multiple databases, repeat this option

binlog-ignore-db= database does not need to be backed up, if you back up multiple databases, repeat this option

3. From the server

Log-bin

server-id=2

Master-host= Host

master-user= User Name

master-password= Password

master-port= Port

replicate-do-db= the name of the database you want to back up, and if you back up multiple databases, repeat this option

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Just as simple as the above configuration is OK.

Related commands on the primary server:

show master status
show slave hosts
show logs
show binlog events
purge logs to 'log_name'
purge logs before 'date'
reset master(老版本flush master)
set sql_log_bin=

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.