Mysql 主从同步



Mysql master slave syn (for window7)
1. the mysql version is the same,
2. download mysql, for version 5.6
3. if free installation version, you need configure my.ini as follow, notice the server_id must be

different from each other
server_id=1
basedir = D:\MySQL\mysql
datadir = D:\MySQL\mysql\data
port = 3307
log-bin=mysql-bin
replicate-wild-do-table = tvugs.%
replicate_wild_ignore_table = mysql.%

4. run cmd as administrator. Enter the mysql to find mysqld, run the command
mysqld --install mysql_service_name --defaults-file="D:\MySQL\mysql\my.ini
note, mysql_service_name, you can name it arbitrary.

5. launch the mysql,
net start mysql_service_name(the name is before you named)

6.  create an account and authorize the slave at master, you'd beeter not use root
GRANT REPLICATION SLAVE ON *.* to 'slaveuser'@'%' identified by '123456'

7. login the master and show the master status
mysql>show master status;
+------------------+----------+--------------+------------------+
   | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
   +------------------+----------+--------------+------------------+
   | mysql-bin.000004 |      308 |              |                  |
   +------------------+----------+--------------+------------------+
note, don't operate the master in case the value of the master status is changed.

8. configure the slave
mysql>change master to

master_host='192.168.145.222',master_port=3307,master_user='slaveuser',master_passwo

rd='123456', master_log_file='mysql-bin.000004',master_log_pos=308;  

if master_port is 3306, you can ignore it, or you need it and not single qote, as the

master_log_pos

mysql>start slave;

9. view the slave copy status
mysql>show slave status
if Slave_IO_Running and Slave_SQL_Running are both yes, it is just ok.


for linux or centos it is the same as windows 7, but has a little difference.

1. use find command to find the file my.cnf (/usr/my.cnf  /etc/my.cnf)

2. service mysql restart.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值