MySQL Master-slave replication

Source: Internet
Author: User
Tags unique id

1, edit the master master server my.cnf

VI /ETC/MY.CNF

Add the following content

[mysqld]  log-bin=mysql-bin   // [must] enable binary logging  server-id=222      //[must] server unique ID, default is 1, usually take IP last paragraph

2, modify the MY.CNF configuration from the server

VI /ETC/MY.CNF

Add the following content

[Mysqld]log-bin=mysql-bin   //[not required] enable binary log server-id=226      // [must] server unique ID, default is 1, usually take IP last paragraph

3. Restart all master and slave servers

Systemctl Restart Mysqld

4. Log in to the master server and create a master-slave copy Account

Mysql-u root-'slave'@'%'q123456  '// Create a Slave account

5. View server log files and versions

Mysql> Show Master Status\g//with \g executed, otherwise not in format

6. Log in from the server, set slave copy

mysql> Change Master to master_host='190.168.0.150', master_port=3306,
master_user='slave', master_password='q123456'
  , master_log_file='mysql-bin.000001', master_log_pos=308;//Pay attention to the master here _log_file and Master_log_pos are the same as the log files and versions of the master server above
mysql> start slave;

7. View slave status

Mysql> Show slave status\g     //band on \g execution, otherwise the format is incorrect

MySQL Master-slave replication

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.