How to synchronize data between two MySQL Databases

Source: Internet
Author: User


1. Install the configuration

Install MySQL on both servers in the/usr/local/MySQL directory (the installation steps are omitted. Refer to the relevant documentation ), the IP addresses of the two servers are 192.168.0.1 and 192.168.0.2. We use 192.168.0.1 as the master database and 192.168.0.2 as the slave server. We adopt one-way synchronization, that is, the master data is the master data, then, slave takes the initiative to sync data back from the master.

The configuration of the two servers is the same, we copy the key configuration file, the default configuration file is in the/usr/local/MySQL/share/MySQL directory, there are my-large.cnf, respectively, my-medium.cnf, my-small.cnf and so on several writers, we just test, use my-medium.cnf on the line. After MySQL is installed, the default configuration file is specified in the database storage directory. We use 4.1.x, therefore, the configuration file should be in the/usr/local/MySQL/var directory, so you can copy the configuration file:

CP/usr/local/MySQL/share/MySQL/my-medium.cnf/usr/local/MySQL/var/My. CNF two servers perform the same copy configuration file operation.

2. Configure the master server

We need to configure 192.168.0.1 as the primary MySQL Server (master), so we need to consider that we need to synchronize that database and use that user for synchronization. Here we will use the root user for synchronization for the sake of simplicity, in addition, you only need to synchronize the database ABC.

Open the configuration file:

VI/usr/local/MySQL/var/My. CNF find the following information:

# Required unique ID between 1 and 2 ^ 32-1 phpchina Open SourceCommunityPortal

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.