MySQL Master-slave configuration

Source: Internet
Author: User
Tags mysql command line

Install MySQL on two machines, synchronize the contents of two databases with SYRNC Configure the primary  Add Server-id = 1log-bin=mysql-bin (generate binary log) in config file vi/etc/my.cnf above these two are the two optional binlog-do-db=databasename1 that must be added below , databasename2binlog-ignore-db=databasename1,databasename2binlog-do-db= needs to replicate the database name, multiple database names, separated by commas. Binlog-ignore-db= does not need to replicate database library names, multiple database names, separated by commas.  [[email protected] bin]# mysql-u root-p (mysql command line ends with; end)   Authorization mysql> grant replication Slave on *. * to ' Wang ' @ ' 192.168.72.132 ' identified by ' Wangyongyan ', on (corresponding to which library authorization) to (authorization to that user) @ (from IP) IP becomes percent sign is for any user Identifiedby (password)  flush privileges; (Refresh authorization)  flush tables with read lock; (Lock read to brush memory to disk)  show master status; (keep data unchanged)   configuration from open config file vi/etc/my.cnf Modify must add Server-id = 2 (can be any number cannot be the same as the master) comment out Log-bin=mysql-bin optional add Restart the MySQL service with the master's counterpart Replicate-do-db=databasename1,databasename2replicate-ignore-db=databasename1,databasename2/etc/ Init.d/mysqld restart mysql-u Root-p slave stop; (Stop slave service)  change master to master_host= ' 192.168.31.131 ', master_port=3306, master_user= ' Wang ', master_ Password= ' WangyonGyan ', master_log_file= ' mysql-bin.000003 ', master_log_pos=478; (The last two options are the one that the Lord lock remains the same value)  slave start, (start slave service) show slave status\g; (check the status from) slave_io_running and Slave_sql_ Running: Whether the state is yes  in the Lord unlock unlock tables;  test Master in the Lord to view the existing library show databases; Create library creation DATABASW Library name; View from the top of the library that you just created show databases; Copy a table in the Lord Show create table aming.pre_forum_post; Open the table after the statement copy and paste, re-view will come out a table

MySQL master-slave configuration

Related Article

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.