Simple MySQL master-slave configuration

Source: Internet
Author: User

  1. installation of 2 Mysql:ip Address 192.168.1.1 (Master master database), respectively, 192.168.1.2 (slave from Database), Ps:mysql version 5.5 or higher.

  2. Modify Master master database my.cnf file ( need to restart MySQL to complete the modification)
    [Mysqld]server-id = 1   binlog-do-db=test #要同步的数据库, if you have more than one database, repeat this parameter for each database row Log-bin=mysql-bin #要生成的二进制日记文件名称
  3. Master Main Library Add User=slave is responsible for synchronizing the main library data ( Note: The initial data of the master-slave database should be consistent )

    #建立一个帐户slave, and can only be accessed from 192.168.1.2 this address (slave), the password is 123456. Create user ' slave ' @ ' 192.168.1.2 ' identified by ' 123456 '; #为slave用户设置REPLICATION slave permissions Grant REPLICATION slave on * * to ' Slave ' @ ' 192.168.1.2 ';
  4. Master Main Library sql: mysql> Show Master Status ;

    Remember the value of the File,position field

  5. Modify slave from library my.cnf (modify to complete restart MySQL)
    change Master to master_host= ' 192.168.1.1 ', master_port=3306,master_user= ' slave ', master_password= ' 123456 ', master_ Log_file= ' mysql-bin.000002 ', master_log_pos=1302; 

    master_log_file, master_log_pos corresponds to the value of the file,position in the 4th step.
    Open slave:mysql> slave start;
    Available by: mysql> show  slave status;   View slave status

  6. done.

Simple MySQL master-slave configuration

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.