Mysql Command master-to-master

Source: Internet
Author: User

Mysql Command master-to-master 1. the select statement combines two string fields into one field: select concat (a, B) as c from tables 2. query by date group select DATE_FORMAT (created_at, '% Y-% m-% d % H') as t from tables group by t 3. mysql creates a user/adds a remote user/modifies the user password. First, enter the mysql command: mysql-uroot-proot-> create user username @ '2017. 168.39.% 'identified BY 'Password'; configure remote-> grant replication slave, replication client on *. * TO username @ '2017. 168.39.% 'identified BY 'Password'; modify Password-> update mysql. user set password = PASSWORD ('xxx') where user = 'username';-> flush privileges; 4. master-to-master: configure remote: grant replication slave, replication client on *. * TO username @ '2017. 168.39.% 'identified BY 'Password'; create a master:-> slave stop;-> change master to master_host = '2017. 168.0.2 ',-> master_user = 'backup',-> master_password = 'back',-> master_log_file = 'mysql-bin.20.01 ',-> master_log_pos = 106;-> slave Start;-> show slave status \ G 4. View server_id. Note that the server_id of the master-to-master servers cannot be the same and must be modified. -> Show variables like 'server _ id'; Modify server_id-> set global server_id = 10; 5. view the auto_increment_increment and auto_increment_offset values:-> show variables like 'Auto _ inc % '; 6. the auto_increment_offset value must be set to different master-to-master servers. For example: auto_increment_increment = 2 # auto_increment_offset = 1. For the second server: auto_increment_increment = 2 # It is the starting value auto_increment_offset = 2 7. mysql has the following 14 remote connection permissions: select, insert, update, delete, create, drop, index, alter, grant, references, reload, shutdown, process, and file.

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.