window環境下mysql實現主從同步

來源:互聯網
上載者:User

標籤:.com   root   replica   star   lin   status   class   window   index   

同一台電腦配置mysql5.5兩個執行個體,分別在3310和3311兩個連接埠。設定3310為主庫,3311為從庫。

最終效果如下:

 

 

3310主庫:

grant replication slave,reload,super on *.* to slave@192.168.1.110 identified by ‘123456‘;
-- my.ini檔案中的[mysqld]下增加server-id = 1replicate-do-db=test1

3311從庫:

-- my.ini檔案中的[mysqld]增加server-id = 2replicate-do-db=test1relay-log=relay-binrelay-log-index=relay-bin-index
stop slave;

-- 【方法一】
change master to master_host=‘192.168.1.110‘,master_port=3310,master_user=‘slave‘,master_password=‘123456‘;-- 【方法二】若指定position同步,請使用(後面兩個參數通過主庫命令“show master status;”查看):
change master to master_host=‘192.168.1.110‘,master_port=3310,master_user=‘slave‘,master_password=‘123456‘,
master_log_file=‘mysql-bin.000001‘,master_log_pos=107;

start slave;

 

至此,配置完畢,通過命令:

show slave status\G;

查看同步是否串連成功,關鍵計量為:

Slave_IO_Running: YesSlave_SQL_Running: Yes

 

備忘:

-- 查看server_id:show VARIABLES like ‘server_id‘;
-- 主伺服器上查看主機狀態,File和Positionshow master status;

 

預設配置的mysql中root賬戶無密碼,通過如下方式修改:

mysql -u root -penter password:(此處直接斷行符號)
-- 修改密碼為123456set password=password(‘123456‘);-- 重新整理許可權flush privileges;

 

附my.ini設定檔下載:

 my.ini下載

 

參考:

https://www.cnblogs.com/puchengjie/p/5220676.html

 

主從同步故障解決方案:

Slave_SQL_Running: No

http://blog.51cto.com/kerry/277414

http://blog.chinaunix.net/uid-21505614-id-289477.html

 

linux下配置主從參考:

http://blog.chinaunix.net/uid-21505614-id-289477.html

 

window環境下mysql實現主從同步

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.