Windows mysql 主從服務器配置

參考資料

mysql replication on windows server

  1. Configure on both servers a different server-id, and activate the binary log on the master. If it is not already done, the most typical way to do that is modify the my.ini file and restart the service (net restart mysql):
[mysqld]
log-bin
server-id = 1

Make also sure that the master is accesible from the slave node and it is not bound to localhost (bind-address = 127.0.0.1)

  1. Create a user on the master for the slave to connect with REPLICATION SLAVE privileges (use MySQL-command line for this):
mysql master> CREATE USER 'user_name'@'ip.of.the.slave' IDENTIFIED BY 'password';
mysql master> GRANT REPLICATION SLAVE ON *.* TO 'user_name'@'ip.of.the.slave'; 
  1. Make a backup of the master and apply it to the slave. There are several ways to do that (stopping the server and copying the files works), but the easiest would be to se mysqldump (navigate to the bin directory of your sql-server installation (f.e. C:\Program Files\MySQL\MySQL Server 5.7\bin). Also you may need to provide credentials by appending this to both commands: -uroot -pPassword)
(on the master windows command line) mysqldump --all-databases --master-data > dump.sql
(on the slave windows command line ) mysql < dump.sql

At the beginning the dump.sql you will find a line like this:

-- CHANGE MASTER TO MASTER_LOG_FILE = 'file_name', MASTER_LOG_POS = file_pos;

Use those parameters to configure the replication on the slave:

mysql slave> CHANGE MASTER TO MASTER_HOST = 'ip.of.the.master',
                 MASTER_USER = 'user_name_you_just_created',
                 MASTER_PASSWORD = 'password_you_just_defined',
                 MASTER_LOG_FILE = 'file_name',
                 MASTER_LOG_POS = file_pos;

(beware, no quotes for integers, like MASTER_LOG_POS).

  1. If everything is ok until now, just start replication on the slave:
mysql slave> START SLAVE;

To check that it is running, execute:

mysql slave> SHOW SLAVE STATUS;

And look for:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
GTID-based replication is a bit different, and I have not mentioned it.

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末奖亚,一起剝皮案震驚了整個濱河市啼县,隨后出現(xiàn)的幾起案子躬拢,更是在濱河造成了極大的恐慌,老刑警劉巖炼幔,帶你破解...
    沈念sama閱讀 219,188評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異史简,居然都是意外死亡乃秀,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,464評論 3 395
  • 文/潘曉璐 我一進店門圆兵,熙熙樓的掌柜王于貴愁眉苦臉地迎上來环形,“玉大人,你說我怎么就攤上這事衙傀√б鳎” “怎么了?”我有些...
    開封第一講書人閱讀 165,562評論 0 356
  • 文/不壞的土叔 我叫張陵统抬,是天一觀的道長火本。 經(jīng)常有香客問我,道長聪建,這世上最難降的妖魔是什么钙畔? 我笑而不...
    開封第一講書人閱讀 58,893評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮金麸,結果婚禮上擎析,老公的妹妹穿的比我還像新娘。我一直安慰自己挥下,他們只是感情好揍魂,可當我...
    茶點故事閱讀 67,917評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著棚瘟,像睡著了一般现斋。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上偎蘸,一...
    開封第一講書人閱讀 51,708評論 1 305
  • 那天庄蹋,我揣著相機與錄音瞬内,去河邊找鬼。 笑死限书,一個胖子當著我的面吹牛虫蝶,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播倦西,決...
    沈念sama閱讀 40,430評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼能真,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了调限?” 一聲冷哼從身側響起舟陆,我...
    開封第一講書人閱讀 39,342評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎耻矮,沒想到半個月后秦躯,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,801評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡裆装,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,976評論 3 337
  • 正文 我和宋清朗相戀三年踱承,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片哨免。...
    茶點故事閱讀 40,115評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡茎活,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出琢唾,到底是詐尸還是另有隱情载荔,我是刑警寧澤,帶...
    沈念sama閱讀 35,804評論 5 346
  • 正文 年R本政府宣布采桃,位于F島的核電站懒熙,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏普办。R本人自食惡果不足惜工扎,卻給世界環(huán)境...
    茶點故事閱讀 41,458評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望衔蹲。 院中可真熱鬧肢娘,春花似錦、人聲如沸舆驶。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,008評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽贞远。三九已至畴博,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間蓝仲,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,135評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留袱结,地道東北人亮隙。 一個月前我還...
    沈念sama閱讀 48,365評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像垢夹,于是被迫代替她去往敵國和親溢吻。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,055評論 2 355

推薦閱讀更多精彩內(nèi)容