MySQL涓讳粠澶嶅埗
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL涓讳粠澶嶅埗相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%89%a7%e8%a1%8c' title='鎵ц'>鎵ц min 灏辨槸 浣跨敤 sla current mysq set
涓讳粠澶嶅埗锛?/p>
銆€銆€mysql瑕佸仛鍒颁富浠庡鍒讹紝鍏跺疄渚濋潬鐨勬槸浜岃繘鍒舵棩蹇楋紝鍗筹細鍋囪涓绘湇鍔″櫒鍙獳锛屼粠鏈嶅姟鍣ㄥ彨B锛涗富浠庡鍒跺氨鏄?/p>
銆€銆€B璺熺潃A瀛︼紝A鍋氫粈涔堬紝B灏卞仛浠€涔堛€傞偅涔圔鎬庝箞鍚屾A鐨勫姩浣滃憿锛熺幇鍦ˋ鏈変竴涓棩蹇楀姛鑳斤紝鎶婅嚜宸辨墍鍋氱殑澧炲垹鏀规煡鐨勫姩浣?/p>
銆€銆€鍏ㄩ兘璁板綍鍦ㄦ棩蹇椾腑锛孊鍙渶瑕佹嬁鍒拌繖浠芥棩蹇楋紝鐓х潃鏃ュ織涓婇潰鐨勫姩浣滄柦鍔犲埌鑷繁韬笂灏卞彲浠ヤ簡銆傝繖鏍峰氨瀹炵幇浜嗕富浠庡鍒躲€?/p>
鐜锛?/p>
銆€銆€涓诲簱锛氶樋閲屼簯 MySQL5.7 锛圵indows Server2008锛?/p>
銆€銆€浠庡簱锛氫釜浜鸿绠楁満 MySQL5.7 锛圵in 10锛?/p>
1銆侀厤缃甿aster锛堜富搴擄級
銆€銆€鎵惧埌MySQL鐨勯厤缃枃浠讹紝涓€鑸綅浜嶮ySQL瀹夎浣嶇疆鏍圭洰褰曟垨鑰匘ata鏂囦欢鐩綍涓?/p>
銆€銆€鍦╗mysqld]涓嬭竟锛屾坊鍔犱互涓嬩笁涓弬鏁?/p>
銆€銆€銆€銆€log-bin=mysql-bin //灏唌ysql浜岃繘鍒舵棩蹇楀彇鍚嶄负mysql-bin
銆€銆€銆€銆€binlog_format=mixed //浜岃繘鍒舵棩蹇楃殑鏍煎紡锛屾湁涓夌锛歴tatement/row/mixed,鍏蜂綋鍒嗗埆涓嶅鍋氳В閲婏紝杩欓噷浣跨敤mixed
銆€銆€銆€銆€server-id=101 //涓烘湇鍔″櫒璁剧疆涓€涓嫭涓€鏃犱簩鐨刬d渚夸簬鍖哄垎锛岃繖閲屼娇鐢╥p鍦板潃鐨勬渶鍚庝竴浣嶅厖褰搒erver-id
2銆侀厤缃畇lave锛堜粠搴擄級
銆€銆€姝ラ鍚?锛宻erver-id涓嶅悓鍗冲彲
3銆佸垎鍒噸鍚富搴撲粠搴?/p>
4銆佸湪涓诲簱涓婁负浠庡簱鍒嗛厤涓€涓处鍙?/p>
Microsoft Windows [鐗堟湰 6.1.7601] 鐗堟潈鎵€鏈?(c) 2009 Microsoft Corporation銆備繚鐣欐墍鏈夋潈鍒┿€? C:\Users\Administrator>mysql -u root -p Enter password: **** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 5.7.20-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. mysql> grant replication slave on *.* to 鈥榮lave鈥楡鈥?鈥?identified by 鈥榮lave鈥?/span>; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> show master status; +------------------+----------+--------------+------------------+--------------- ----+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_ Set | +------------------+----------+--------------+------------------+--------------- ----+ | mysql-bin.000002 | 1483 | | | | +------------------+----------+--------------+------------------+--------------- ----+ 1 row in set (0.00 sec) mysql>
鍏朵腑“grant replication slave on *.* to 鈥榮lave鈥楡鈥?鈥?identified by 鈥榮lave鈥?” 锛屽湪涓诲簱涓婁负slave璐﹀彿鍒嗛厤浜唕eplication 鏉冮檺
“show master status;” 鏌ョ湅涓绘湇鍔″櫒BIN鏃ュ織鐨勪俊鎭紙鎵ц瀹屼箣鍚庤褰曚笅杩欎袱鍊硷紝鐒跺悗鍦ㄩ厤缃畬浠庢湇鍔″櫒涔嬪墠涓嶈瀵逛富鏈嶅姟鍣ㄨ繘琛屼换浣曟搷浣滐紝鍥犱负姣忔鎿嶄綔鏁版嵁搴撴椂杩欎袱鍊间細鍙戠敓鏀瑰彉锛?
5銆侀厤缃粠搴?/p>
mysql> stop slave; ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection id: 3 Current database: mysql Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> show slave status; Empty set (0.00 sec) :: 姝ゅ閰嶇疆鐨勬槸涓诲簱鐨勫湴鍧€ mysql> change master to master_host=鈥?*.**.**.**鈥? Query OK, 0 rows affected (0.07 sec) mysql> change master to master_user=鈥榮lave鈥? Query OK, 0 rows affected, 2 warnings (0.04 sec) mysql> change master to master_password=鈥榮lave鈥? Query OK, 0 rows affected, 2 warnings (0.04 sec) :: 涓庝笂涓€姝ュ湪涓诲簱涓婃煡璇㈢殑缁撴灉涓€鑷村嵆鍙? mysql> change master to master_log_file=鈥榤ysql-bin.000002鈥? Query OK, 0 rows affected, 1 warning (0.04 sec) :: 涓庝笂涓€姝ュ湪涓诲簱涓婃煡璇㈢殑缁撴灉涓€鑷村嵆鍙? mysql> change master to master_log_pos=1483; Query OK, 0 rows affected (0.04 sec) :: 寮€濮嬩富浠庡鍒? mysql> start slave; Query OK, 0 rows affected (0.01 sec)
6銆侀厤缃畬鎴?/p>
濡傛灉涓婅堪姝ラ閮芥甯告墽琛屽畬姣曪紝閭d箞鐜板湪灏遍厤缃畬鎴愪簡
浣跨敤Navicat绛夊彲瑙嗗寲杩炴帴宸ュ叿瀵逛富搴撳仛寤鸿〃銆佹彃鍏ャ€佸垹闄ゃ€佷慨鏀圭瓑鎿嶄綔
浠庡簱浼氶殢涔嬫洿鏂?/p>
以上是关于MySQL涓讳粠澶嶅埗的主要内容,如果未能解决你的问题,请参考以下文章