mysql 的主從備份
阿新 • • 發佈:2018-11-04
圖
master
master 新增使用者
mysql>grant replication slave on *.* to 'repl'@'%' identified by 'repl';
mysql>flush privileges;
master my.cnf
server-id=50
log-bin=/var/lib/mysql/mysql-bin
binlog-do-db=demo1
log-slave-updates=1
重啟
mysqld restart
mysql>flush tables with read lock;
mysql> show master status; (此處記住File名稱和Position值,後面slave伺服器配置時需要用到)
mysqldump test > test.sql
mysql>unlock tables;
slave
slave my.ini
server-id=109
啟動slave
mysqld restart;
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql> change master to
-> master_host='192.168.0.107' ,
-> master_user='repl',
-> master_password='repl',
-> master_log_file='mysql-bin.000001',
-> master_log_pos=713;
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G;
ref url
http://www.cnblogs.com/rwxwsblog/p/4542417.html
http://www.cnblogs.com/gomysql/p/5852607.html