mysql 复制用户_MySQL修改复制用户及密码

在生产环境中有时候需要修改复制用户账户的密码,比如密码遗失,或者由于多个不同的复制用户想统一为单独一个复制账户。对于这些操作应尽可能慎重以避免操作不同导致主从不一致而需要进行修复。本文描述了修改复制账户密码以及变更复制账户。 1、更改复制账户密码[sql] view plaincopyprint?--演示环境,同一主机上的2个实例,主3406,从3506  --当前版本,注:master账户表明是对主库进行相关操作,slave则是对从库进行相关操作  master@localhost[(none)]> show variables like 'version';  +---------------+------------+  | Variable_name | Value      |  +---------------+------------+  | version       | 5.6.12-log |  +---------------+------------+    --主库上的记录  master@localhost[test]> select * from tb1;  +------+-------+  | id   | name  |  +------+-------+  |    1 | robin |  +------+-------+    --从库上的记录  slave@localhost[test]> select * from tb1;  +------+-------+  | id   | name  |  +------+-------+  |    1 | robin |  +------+-------+    --当前从库上的状态信息  slave@localhost[test]> show slave status\G  *************************** 1. row ***************************                 Slave_IO_State: Waiting for master to send event                    Master_Host: 192.168.1.177                    Master_User: repl                    Master_Port: 3406                  Connect_Retry: 60                Master_Log_File: inst3406bin.000001            Read_Master_Log_Pos: 3296006                 Relay_Log_File: relay-bin.000002                  Relay_Log_Pos: 811          Relay_Master_Log_File: inst3406bin.000001               Slave_IO_Running: Yes              Slave_SQL_Running: Yes                Replicate_Do_DB: test,sakila   --仅复制了test以及sakila数据库            Replicate_Ignore_DB:              Replicate_Do_Table:          Replicate_Ignore_Table:         Replicate_Wild_Do_Table:     Replicate_Wild_Ignore_Table:                      Last_Errno: 0                     Last_Error:                    Skip_Counter: 0            Exec_Master_Log_Pos: 3296006                Relay_Log_Space: 978             --主库上复制账户的信息  master@localhost[test]> show grants for 'repl'@'192.168.1.177';  +----------------------------------------------------------------------------------------------------------------+  | Grants for repl@192.168.1.177                                                                                  |  +----------------------------------------------------------------------------------------------------------------+  | GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.1.177' IDENTIFIED BY PASSWORD '*A424E797037BF191C5C2038C039' |  +----------------------------------------------------------------------------------------------------------------+    --修改复制账户密码  master@localhost[test]> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.1.177' IDENTIFIED BY 'replpwd';    --如下查询密码已更改  master@localhost[test]> select user,host,password from mysql.user where user='repl';  +------+---------------+-------------------------------------------+  | user | host          | password                                  |  +------+---------------+-------------------------------------------+  | repl | 192.168.1.177 | *4A04E4FD524292A79E3DCFEBBD46094478F178EF |  +------+---------------+-------------------------------------------+    --更新记录  master@localhost[test]> insert into tb1 values(2,'fred');    --重库上可以查询到刚刚被更新的记录  slave@localhost[test]> select * from tb1;  +------+-------+  | id   | name  |  +------+-------+  |    1 | robin |  |    2 | fred  |  +------+-------+    slave@localhost[test]> stop slave;  Query OK, 0 rows affected (0.02 sec)    slave@localhost[test]> start slave;  Query OK, 0 rows affected (0.01 sec)    --再次查看状态出现了错误提示  slave@localhost[test]> show slave status \G  *************************** 1. row ***************************                 Slave_IO_State: Connecting to master                    Master_Host: 192.168.1.177                    Master_User: repl                    Master_Port: 3406                  Connect_Retry: 60                Master_Log_File: inst3406bin.000001            Read_Master_Log_Pos: 3296438                 Relay_Log_File: relay-bin.000002                  Relay_Log_Pos: 1243          Relay_Master_Log_File: inst3406bin.000001               Slave_IO_Running: Connecting              Slave_SQL_Running: Yes                Replicate_Do_DB: test,sakila                        ....................                  Last_IO_Errno: 1045                  Last_IO_Error: error connecting to master 'repl@192.168.1.177:3406' - retry-time: 60  retries: 1    --更改重库连接密码,该信息记录在从库master.info文件中                  slave@localhost[test]> stop slave;    slave@localhost[test]> change master to                         -> master_user='repl',              -> master_password='replpwd';   Query OK, 0 rows affected, 2 warnings (0.00 sec)    --修改密码后,从库状态正常,以下检查结果不再列出  slave@localhost[test]> start slave;    --查看master.info,密码已更改且为名文  slave@localhost[(none)]> system grep repl /data/inst3506/data3506/master.info  repl  replpwd  2、更换复制账户及密码[sql] view plaincopyprint?master@localhost[test]> GRANT REPLICATION SLAVE ON *.* TO 'repl2'@'192.168.1.177' IDENTIFIED BY 'Repl2';  Query OK, 0 rows affected (0.00 sec)      slave@localhost[test]> stop slave;  Query OK, 0 rows affected (0.28 sec)    master@localhost[test]> insert into tb1 values(3,'jack');  Query OK, 1 row affected (0.00 sec)    slave@localhost[test]> change master to       -> MASTER_USER='repl2',      -> MASTER_PASSWORD='Repl2';  Query OK, 0 rows affected, 2 warnings (0.01 sec)    slave@localhost[test]> system more /data/inst3506/data3506/master.info  23  inst3406bin.000001  3294834  192.168.1.177  repl2  Repl2  3406    ..........    slave@localhost[test]> start slave;  Query OK, 0 rows affected (0.01 sec)    slave@localhost[test]> select * from tb1 where id=3;  +------+------+  | id   | name |  +------+------+  |    3 | jack |  +------+------+  1 row in set (0.00 sec)    slave@localhost[(none)]> show slave status \G  *************************** 1. row ***************************                 Slave_IO_State: Waiting for master to send event                    Master_Host: 192.168.1.177                    Master_User: repl2                    Master_Port: 3406                  Connect_Retry: 60                Master_Log_File: inst3406bin.000001  --Author :Leshami            Read_Master_Log_Pos: 3296871             --Blog   : http://blog.csdn.net/leshami                 Relay_Log_File: relay-bin.000002                  Relay_Log_Pos: 501          Relay_Master_Log_File: inst3406bin.000001               Slave_IO_Running: Yes              Slave_SQL_Running: Yes                Replicate_Do_DB: test,sakila  3、关于change masterCHANGE MASTER TO changes the parameters that the slave server uses for connecting to the masterserver, for reading the master binary log, and reading the slave relay log. It also updates the contentsof the master info and relay log info repositories (see Section 16.2.2, “Replication Relay and StatusLogs”). To use CHANGE MASTER TO, the slave replication threads must be stopped (use STOP SLAVEif necessary). In MySQL 5.6.11 and later, gtid_next [2060] must also be set to AUTOMATIC (Bug#16062608). Options not specified retain their value, except as indicated in the following discussion. Thus, in mostcases, there is no need to specify options that do not change. For example, if the password to connectto your MySQL master has changed, you just need to issue these statements to tell the slave about thenew password: STOP SLAVE; -- if replication was runningCHANGE MASTER TO MASTER_PASSWORD='new3cret';START SLAVE; -- if you want to restart replication MASTER_HOST, MASTER_USER, MASTER_PASSWORD, and MASTER_PORT provide information to theslave about how to connect to its master: Note: Replication cannot use Unix socket files. You must be able to connect to themaster MySQL server using TCP/IP. If you specify the MASTER_HOST or MASTER_PORT option, the slave assumes that the masterserver is different from before (even if the option value is the same as its current value.) In thiscase, the old values for the master binary log file name and position are considered no longerapplicable, so if you do not specify MASTER_LOG_FILE and MASTER_LOG_POS in the statement,MASTER_LOG_FILE='' and MASTER_LOG_POS=4 are silently appended to it. Setting MASTER_HOST='' (that is, setting its value explicitly to an empty string) is not the same asnot setting MASTER_HOST at all. Beginning with MySQL 5.5, trying to set MASTER_HOST to an emptystring fails with an error. Previously, setting MASTER_HOST to an empty string caused START SLAVEsubsequently to fail. (Bug #28796)

小编推荐:欲学习电脑技术、系统维护、网络管理、编程开发和安全攻防等高端IT技术,请 点击这里注册账号,公开课频道价值万元IT培训教程免费学,让您少走弯路、事半功倍,好工作升职加薪!

免责声明:本站系公益性非盈利IT技术普及网,本文由投稿者转载自互联网的公开文章,文末均已注明出处,其内容和图片版权归原网站或作者所有,文中所述不代表本站观点,若有无意侵权或转载不当之处请从网站右下角联系我们处理,谢谢合作!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/380895.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MUL,IMUL指令溢出

MUL 用途: 该指令完成两个无符号值的乘法运算。   语法结构/举例   mul regB|memB   mul bl   mul regW|memW   mul [aword]   仅80386有:   mul regDW|memDW mul ebx   示范代码   DATASEG   multiplicand dw 1024   multiplier …

求1+2+......+100的和

如何求12…100的和?有很多方法,这里我介绍用三种循环方法去求12…100的和 方法一:for循环: 代码如下: /**1. 求12......100的和2. 方法1:for循环*/ public class Demo2 {public static void main(String[…

台湾游戏企业抢滩大陆 研发成竞争核心

近日,台湾游戏企业进驻大陆设立研发机构、产品同大陆企业联合运营、大陆企业的产品进入台湾联运,以及最新的政策新闻,都将大陆和台湾这对本是同根的产业兄弟推上了风口浪尖。 在正在举行的“第二届中国优秀游戏制作人评选大赛”上&#xff0c…

phpstud如何安装mysql新版_MySQL_图解MySQL数据库的安装和操作,一、MySQL下载与安装 1、 - phpStudy...

图解MySQL数据库的安装和操作一、MySQL下载与安装1、下载介绍MySQL相信大家一定听说过,如果不知道它是干什么的,可以去google一下。MySQL的大本营:http://www.mysql.com/MySQL的下载地址:http://dev.mysql.com/downloads/ 因为要从…

erlang小技巧

.列表操作 lists:foreach(fun(X) -> io:format("E~p~n",[X]) end, [1,2,3]). lists:duplicate(10, 16#f). % [15,15,15,15,15,15,15,15,15,15] "abc-123" -> "abc" no_vsn(Name) -> lists:takewhile(fun($-)->false;(_)-> true …

mysql 插入中文 ERROR 1366 (HY000): Incorrect string value: '\xE7\x8E\x9E\x97' for column

1、出现这个问题,是因为我们的字符编码设置出现了问题,用cmd打开命令终端,查看我们的数据库设置: 2、输入命令use crm(crm是我创建的数据库,大家在修改时换成自己的数据库名即可) 再输入:show …

handlersocket mysql_Mysql插件之HandlerSocket的安装、配置、使用

HandlerSocket简介HandlerSocket是针对Mysql的一个NoSQL插件,它作为一个守护进程工作在mysqld进程里面,接收tcp连接,并处理来自客户端的请求。HandlerSocket不支持SQL查询,作为替代,它支持表的简单的CRUD操作。由于下面的原因&…

【转】TeeChart的用法

/// <summary> /// 获得数据集 /// </summary> /// <param name"sqlStr">传递查询语句</param> /// <returns>返回数据集</returns> public static DataSet GetDataSet(string sqlStr) { string conns…

java,jdk安装,配置环境变量,window10系统

1、找到我们要安装的jdk软件&#xff0c;软件下载我就不介绍了&#xff0c;jdk下载连接地址 然后安装&#xff0c;一直点下一步就可以了&#xff0c;这里不建议跟换软件目录&#xff0c;毕竟第一次用&#xff0c;出了什么错就不好弄了&#xff0c;注&#xff1a;记得软件的安装…

solr mysql数据注入_(solr系列:四)将mysql数据库中的数据导入到solr中

在前面的博文中&#xff0c;已完成了在tomcat中对solr的部署&#xff0c;为solr添加了一个自定义的core,并且引入了ik分词器。那么该如何将本地的mysql的数据导入到solr中呢&#xff1f;准备工作&#xff1a;1、mysql数据源&#xff1a;myuser库中的user表(8条数据)/*Navicat M…

40种Javascript中常用的使用小技巧【转】

1. οncοntextmenu"window.event.returnValuefalse" 将彻底屏蔽鼠标右键< table border οncοntextmenureturn(false)>< td>no< /table> 可用于Table 2. < body onselectstart"return false"> 取消选取、防止复制 3. οnpaste&q…

超链接去下划线

在a标签里加上 style"text-decoration: none

Silverlight学习笔记(三):创建第一个Silverlight应用程序

在开始创建程序之前&#xff0c;还是要提一下关于Silverlight开发环境搭建的问题。如果使用VS2010&#xff0c;这可以搭建Silverlight4的开发环境。我推荐大家看这篇由大牛jv9撰写的【轻松建立Silverlight 4开发环境】。 我使用的是VS2008&#xff0c;所以要搭建的是Silverlig…

按钮旁边加一个提示_地铁站的那些“红色按钮”,你知道是干啥用的吗?乱按可能被拘留...

地铁紧急停车按钮图片来自网络位置&#xff1a;站台两侧墙壁上&#xff0c;靠近列车车头、车尾两侧。外观&#xff1a;上锁的红色四方小盒子&#xff0c;按钮为红色&#xff0c;旁边写有“紧急停车按钮”等字样。使用&#xff1a;紧急时刻击碎中间玻璃&#xff0c;按压按钮。红…

java中的局部变量、成员变量、类变量

局部变量&#xff1a;在方法、构造函数或者语句块中定义的变量被称为局部变量。 特点&#xff1a;变量的声明和初始化都是在方法中&#xff0c;方法结束后&#xff0c;变量就会自动销毁。 例&#xff1a;下面代码块的s2 成员变量&#xff1a;成员变量是定义在类中&#xff0c;…

根据F12在页面中调整div的大小

我们先随便写一个div大小&#xff0c;然后在chrome浏览器打开&#xff0c;显示效果&#xff1a; #logo{border: 1px solid black;width: 1300px;height: 50px;} .top{border: blue solid 1px;width: 420px;height: 50px;float: left;}<div id"logo"><div c…

头文件

1、头文件用于声明而不是用于定义 定义只可以出现一次&#xff0c;而声明可以出现多次。下列语句是一些定义&#xff0c;不应该放在头文件里&#xff1a; extern int ival 10; double fica_rate; 虽然ival声明为extern&#xff0c;但是它有初始化式&#xff0c;代表这条语句是…

删除了注册表winsock项及winsock2项怎么办

国庆节期间要值一天班&#xff0c;看看网站有没有什么问题&#xff0c;可是打开电脑去上不了网&#xff0c;于是在网上寻找答案&#xff0c;就这么着看到一个贴子&#xff0c;让删除注册表中的winsock及winsock2两项&#xff0c;哎&#xff0c;这一删可出大事了&#xff0c;网更…

mysql 数据库设计规范_MYSQL数据库设计规范与原则

MYSQL数据库设计规范1、数据库命名规范采用26个英文字母(区分大小写)和0-9的自然数(经常不需要)加上下划线_组成;命名简洁明确(长度不能超过30个字符);例如&#xff1a;user, stat, log, 也可以wifi_user, wifi_stat, wifi_log给数据库加个前缀;除非是备份数据库可以加0-9的自然…

The security settings could not be applied to the database because the connection has failed安装Mysql

安装msql出现这个问题&#xff0c;&#xff0c;百度了好久才解决了问题&#xff0c;说一下怎么解决的吧 把以前安装的Mysql删除打开C盘&#xff0c;点击查看&#xff0c;然后点击隐藏的项目&#xff0c;这时候目录会出现ProgramData文件&#xff0c;然后点击这个文件&#xff…