程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> mysql操作命令master-to-master

mysql操作命令master-to-master

編輯:MySQL綜合教程

mysql操作命令master-to-master   1.select語句中把兩個字符串字段合並成一個字段: select concat(a, b) as c from tables   2.按日期分組查詢 select DATE_FORMAT( created_at, '%Y-%m-%d %H' )  as t from tables group by t   3.mysql創建用戶/添加遠程/修改用戶密碼 先進入mysql命令:mysql -uroot -proot ->create user username@'192.168.39.%' IDENTIFIED BY 'password'; 配置遠程 ->GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO username@'192.168.39.%' IDENTIFIED BY 'password'; 修改密碼 ->update mysql.user set password=PASSWORD('xxx') where user='username'; ->flush privileges;   4.master-to-master 先配置遠程: GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO username@'192.168.39.%' IDENTIFIED BY 'password'; 建立master: ->slave stop; ->change master to master_host='192.168.0.2', ->master_user='backup', ->master_password='back', ->master_log_file='mysql-bin.000001', ->master_log_pos=106;   ->slave start; ->show slave status\G   4.查看server_id,注意master-to-master時,兩個服務器的server_id不能一樣,需要修改。 ->show variables like 'server_id'; 修改server_id ->set global server_id=10;   5.查看auto_increment_increment與auto_increment_offset值: ->SHOW VARIABLES LIKE 'auto_inc%';   6.兩個服務器master-to-master,必須設置auto_increment_offset值為不同,如下: 第一台: auto_increment_increment =2  #為開始值 auto_increment_offset = 1 第二台: auto_increment_increment =2  #為開始值 auto_increment_offset = 2   7.mysql遠程鏈接權限有以下14個: select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved