MySQL distributed master-slave Configuration

Source: Internet
Author: User
Recently, a project was designed to implement the distributed mysql design. It was previously done, but this time it went a little deeper. Mysql has a lot of distributed content, so I just want

Recently, a project was designed to implement the distributed mysql design. It was previously done, but this time it went a little deeper. Mysql has a lot of distributed content, so I just want

Recently, a project was designed to implement the distributed mysql design. It was previously done, but this time it went a little deeper. Mysql has a lot of distributed content, so I want to write something to back it up for myself. If I forget it, I can look back.

The ZIP mysql version I downloaded is quite convenient to install. The installation procedure is as follows:

1. Decompress mysql-noinstall-5.0.37-win32.zip to a directory and add it to the E: \ mysql directory.
2. Compile the mysql running configuration file my. ini.
My. ini
-----------------------------
[WinMySQLAdmin]
# Specify the mysql Service Startup File
Server = E: \ mysql \ master \ bin \ mysqld-nt.exe

[Mysqld]
# Set the installation directory of mysql
Basedir = E :\\ mysql \ master

# Set the data storage directory of the mysql database, which must be data or \ xxx \ data
Datadir = E: \ mysql \ master \ data
# Set the character set of the mysql server
Default-character-set = gbk

[Client]
# Set the character set of the mysql client
Default-character-set = gbk
-----------------------------

3. Install the mysql Service
Enter directory E: \ mysql \ master \ bin from the MS-DOS window and run the following command:
Mysqld -- install master -- defaults-file = E: \ master \ my. ini

4. Start the mysql master database
In the above command window, enter the command: net start master
In this way, the mysql master service is started.

This is the primary Mysql installed. To install mysql, you only need to copy the master folder and rename it, such as slave1.

Then start Installation

1. Enter the directory E: \ mysql \ slave1 \ bin from the MS-DOS window and run the following command:
Mysqld -- install slave1 -- defaults-file = E: \ mysql \ slave1 \ my. ini

2,

In the above command window, enter the command: net start slave1
In this way, mysql's first slave database slave1 service is started.

Finally, you will see the following in regedit:


Mysql is equivalent to master, and mysql3 is equivalent to slave1.

.

After the installation is complete, configure the database user. To allow access from the database to the primary database, you must create an account in the primary database to use this account to log on to the primary database.

You can use a tool to create an account. I use navicat 8 for mysql. If the name is slave and the password is also slave, host % indicates that any IP host can connect to this.

Configure my. ini below

If you do not find my. ini in the downloaded file, select one of the my-large.ini or several others and change it to my. ini.

MASTER:

  • Log-bin = mysql-bin// Log file name, which is required because logs are used to synchronize data to the master node.
  • Binlog-ignore-db = mysql// No synchronization is required
  • From:

  • Master-port =3306
  • Master-user = slave// Username of the slave login master
  • Master-password = slave// The password of the slave login master
  • I am sitting in the XP of the local machine, so the ip address is 127.0.0.1, it is best not to write localhost. The tables synchronized from the master and slave databases, including tables, must have the same structure.

    This configuration is fine. You can discuss any issues.

  • 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.