您的位置:首页 > 数据库 > MySQL

MySQL复制中启动从库,日志中提示用户名及密码问题

2016-08-28 00:00 447 查看
摘要: MySQL复制中的错误日志中提示
[Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommmended.Please consider using the USER and PASSWORD connection options for START SLAVE;see the 'START SLAVE Syntax'......

重现模拟环境:

1.在主库上创建复制账户
create user repl ;
grant replication slave , replication client on *.* to repl@'192.168.6.16' identified by 'repl';
2.建库建表、插入数据
use test;
create table t(id int);
insert into t values(1),(2);
3.dump主库数据
mysqldump -uroot -p -S /data/mysql5.6_data/mysql.sock --lock-tables -R -E --triggers --master-data=2 -A > ./all.sql
scp all.sql mysql@192.168.6.16:/home/mysql
4.在主库上插入数据,模拟数据是否同步过来。
/app/mysql5.6/bin/mysql -uroot -p -S /data/mysql5.6_data/mysql.sock
use test;
insert into t values(3),(4);
flush logs;
insert into t values(5),(6);

5.将主库dump的数据恢复到从库
mysql -uroot -p -S /data/mysql5.6_data/mysql.sock < ./all.sql #从库上操作
6.在从库上开启复制
mysql -uroot -p -S /data/mysql5.6_data/mysql.sock
change master to master_host='192.168.6.15',master_user='repl',master_password='repl',MASTER_LOG_FILE='binlog.000003', MASTER_LOG_POS=743;
#主库的binlog及pos可以在dump的文件中可以找到

start slave;
show slave status\G;

7.在从库上查看数据
use test;
select * from t;

当我们查看slave的错误日志:
会出现如下提示信息:
[Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.

1.我们停到从库的复制线程
stop slave;

2.在主库上插入数据 // 模拟主库同时在写。
mysql -uroot -p -S /data/mysql5.6_data/mysql.sock
use test;
insert into t values(7),(8);
3.开启从库复制线程。

start slave user='repl' password='repl';
SHOW SLAVE STATUS\G;

use test;
select * from t;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: