Detailed description of Mysql database master-slave replication deployment

Source: Internet
Author: User
Purpose: To improve the robustness of the Master/Slave server settings. If the master server fails, the slave server that was originally used as a backup can be upgraded to the new master server. Process user requests separately on the master and slave servers to obtain more

Purpose: To improve the robustness of the Master/Slave server settings. If the master server fails, the slave server that was originally used as a backup can be upgraded to the new master server. Process user requests separately on the master and slave servers to obtain more

Master-slave replication Configuration

  • Insert into mysql. user (host, user, password) values ("localhost", "rep1", password ("mysql"); flush privileges; grant replication slave on *. * to rep1@192.168.56.129 identified by 'mysql'; mysql> show master status;

  • Mysqld_safe -- user = mysql & mysql-uroot-pmysql> change master to master_host = '2017. 168.56.128 ', master_user = 'rep1', master_password = 'mysql', master_log_file = 'mysql-bin.000004', master_log_pos = 477;

    Correct execution before execution

    Mysql> start slave;

    If the master database server already has user data, perform the following operations when performing master-slave replication.

    Mysql> flush tables with read lock; mysql> show master status;

    Mysql> unlock tables;

    The operations on the slave server are the same as those in the previous steps. The website space is skipped.

  • Mysql> create database first_tb; mysql> insert into first_tb values (001, 'myself '); mysql> show databases;

    You can view from the database that the website space, Hong Kong virtual host, and database have been fully imported.

    This article is from the "Old Xu's Private food" blog and will not be reposted!

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