Simple MySQL Database master-Slave synchronization configuration

Source: Internet
Author: User

Master configuration:

The code is as follows

Log-bin = Mysql-bin
Server-id = 1
Binlog-do-db = Powerdns #要同步的数据库

Master new Slave Account:

The code is as follows

mysql> GRANT replication Slave on *.* to ' slave ' @ ' 192.168.1.2 ' identified by ' passwd ';
mysql> FLUSH privileges;

Restart Master MySQL, view master status information, remember the file name, POS location.

The code is as follows

Mysql> Show master status;
+------------------+----------+--------------+------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+------------------+----------+--------------+------------------+
|      mysql-bin.000002 | 309 | Powerdns | MySQL |
+------------------+----------+--------------+------------------+
1 row in Set (0.00 sec)

Slave configuration:

The code is as follows

Server-id =2

Start Sync:

The code is as follows

mysql> Change Master to master_host= ' 192.168.1.1 ', master_user= ' slave ', master_password= ' passwd ',
Master_log_file= ' mysql-bin.000002 ', master_log_pos=309;
mysql> START Slave;

To view the slave sync status:

  code is as follows &nbs P;

mysql> show slave statusg;
Slave_io_running:yes
Slave_sql_running:yes

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.