标签:mysql主从
# 让从服务器 能够访问主服务器
1,grant all privileges on *.* to ‘主服务器账号‘@‘从服务器IP‘ identified by ‘主服务器密码‘;
2,flush privileges;
3,SELECT DISTINCT CONCAT(‘User: ‘‘‘,user,‘‘‘@‘‘‘,host,‘‘‘;‘) AS query FROM mysql.user; // 查询当前用户
4,mysql -uroot -h主服务器的IP -p 主服务器的密码
5,主服务器配置
[mysqld]
log-bin=mysql-bin
log-bin=/www/db_logs/mysql-bin.log
server-id=1
binlog-do-db=ybk_db_1 #备份
binlog-ignore-db=mysql #不备份
binlog-ignore-db=ybk_db
binlog-ignore-db=ybk_db_2
binlog-ignore-db=ybk_db_bbs #不复制某个库
6,从服务器配置
server-id = 2
master-connect-retry=60 #如果从服务器发现主服务器断掉,重新连接的时间差(秒)
replicate-do-db =ybk_db_1 #只复制某个库
replicate-ignore-db=mysql
replicate-ignore-db=ybk_db_2
replicate-ignore-db=ybk_db
replicate-ignore-db=ybk_db_bbs #不复制某个库
log_bin=/www/db_logs/mysql-bin.log
relay-log=slave-relay-bin
7,从服务器配置主服务器的一些信息
stop slave;
reset slave;
change master to master_host=‘182.92.230.121‘,master_user=‘copy‘,master_password=‘123456‘,master_log_file=‘mysql-bin.000004‘ ,master_log_pos=240;
change master to master_log_file=‘mysql-bin.000004‘,master_log_pos=240;
start slave;
SHOW SLAVE STATUS\G show master status;
标签:mysql主从
原文地址:http://benchmarking.blog.51cto.com/12343634/1886779