{"id":5148,"date":"2024-11-14T08:24:01","date_gmt":"2024-11-14T00:24:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5148\/"},"modified":"2024-11-14T08:24:01","modified_gmt":"2024-11-14T00:24:01","slug":"mysql%e4%b8%bb%e4%bb%8e%e5%90%8c%e6%ad%a5%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5148\/","title":{"rendered":"mysql\u4e3b\u4ece\u540c\u6b65\u600e\u4e48\u5b9e\u73b0"},"content":{"rendered":"<p><strong> \u4e3b\u4ece\u540c\u6b65\u5b9e\u73b0<\/strong><\/p>\n<p><strong>\u4ec0\u4e48\u662f MySQL \u4e3b\u4ece\u540c\u6b65\uff1f<\/strong><\/p>\n<p>MySQL \u4e3b\u4ece\u540c\u6b65\u662f\u4e00\u79cd\u6570\u636e\u590d\u5236\u673a\u5236\uff0c\u5176\u4e2d\u4e00\u53f0\u670d\u52a1\u5668\uff08\u4e3b\u670d\u52a1\u5668\uff09\u5c06\u6570\u636e\u66f4\u6539\u590d\u5236\u5230\u4e00\u53f0\u6216\u591a\u53f0\u5176\u4ed6\u670d\u52a1\u5668\uff08\u4ece\u670d\u52a1\u5668\uff09\u3002<\/p>\n<p><strong>\u5982\u4f55\u5b9e\u73b0 MySQL \u4e3b\u4ece\u540c\u6b65\uff1f<\/strong><\/p>\n<p><strong>\u5148\u51b3\u6761\u4ef6\uff1a<\/strong><\/p>\n<ul>\n<li>\u4e3b\u670d\u52a1\u5668\u548c\u4ece\u670d\u52a1\u5668\u4e4b\u95f4\u5fc5\u987b\u80fd\u591f\u76f8\u4e92\u8fde\u63a5\u3002<\/li>\n<li>\u4e3b\u670d\u52a1\u5668\u548c\u4ece\u670d\u52a1\u5668\u5fc5\u987b\u4f7f\u7528\u76f8\u540c\u7684 MySQL \u7248\u672c\u3002<\/li>\n<li>\u4ece\u670d\u52a1\u5668\u5fc5\u987b\u5177\u6709\u7528\u4e8e\u590d\u5236\u7684\u6743\u9650\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u5728\u4e3b\u670d\u52a1\u5668\u4e0a\u521b\u5efa\u590d\u5236\u7528\u6237\uff1a<\/strong><\/p>\n<pre>CREATE USER 'repl_user'@'%' IDENTIFIED BY 'strong_password';\nGRANT REPLICATION SLAVE ON *.* TO 'repl_user'@'%';\nFLUSH PRIVILEGES;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u5728\u4e3b\u670d\u52a1\u5668\u4e0a\u542f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8bb0\u5f55\uff1a<\/strong><\/p>\n<pre>SET global binlog_format = 'ROW';\nSET global server_id = 1;  # \u4e3a\u4e3b\u670d\u52a1\u5668\u5206\u914d\u552f\u4e00\u7684 ID<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u83b7\u53d6\u4e3b\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u4fe1\u606f\uff1a<\/strong><\/p>\n<pre>SHOW MASTER STATUS;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u5728\u4ece\u670d\u52a1\u5668\u4e0a\u521b\u5efa\u590d\u5236\u901a\u9053\uff1a<\/strong><\/p>\n<pre>CREATE USER 'repl_user'@'%' IDENTIFIED BY 'strong_password';\nGRANT REPLICATION SLAVE ON *.* TO 'repl_user'@'%';\nSTART SLAVE;\nCHANGE MASTER TO\nMASTER_HOST = 'master_ip_or_hostname',\nMASTER_USER = 'repl_user',\nMASTER_PASSWORD = 'strong_password',\nMASTER_PORT = 3306,\nMASTER_LOG_FILE = 'master_log_file_name',\nMASTER_LOG_POS = master_log_pos;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u68c0\u67e5\u4ece\u670d\u52a1\u5668\u7684\u72b6\u6001\uff1a<\/strong><\/p>\n<pre>SHOW SLAVE STATUS;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p>\u5982\u679c &#8220;Slave_IO_Running&#8221; \u548c &#8220;Slave_SQL_Running&#8221; \u4e3a &#8220;Yes&#8221;\uff0c\u5219\u4e3b\u4ece\u540c\u6b65\u5df2\u6210\u529f\u5efa\u7acb\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e3b\u4ece\u540c\u6b65\u600e\u4e48\u5b9e\u73b0\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\u4ece\u540c\u6b65\u5b9e\u73b0 \u4ec0\u4e48\u662f MySQL \u4e3b\u4ece\u540c\u6b65\uff1f MySQL \u4e3b\u4ece\u540c\u6b65\u662f\u4e00\u79cd\u6570\u636e\u590d\u5236\u673a\u5236\uff0c\u5176\u4e2d\u4e00\u53f0\u670d\u52a1\u5668\uff08\u4e3b\u670d\u52a1\u5668\uff09\u5c06\u6570\u636e\u66f4\u6539\u590d\u5236\u5230\u4e00\u53f0\u6216\u591a\u53f0\u5176\u4ed6\u670d\u52a1\u5668\uff08\u4ece\u670d\u52a1\u5668\uff09\u3002 \u5982\u4f55\u5b9e\u73b0 MySQL \u4e3b\u4ece\u540c\u6b65\uff1f \u5148\u51b3\u6761\u4ef6\uff1a \u4e3b\u670d\u52a1\u5668\u548c\u4ece\u670d\u52a1\u5668\u4e4b\u95f4\u5fc5\u987b\u80fd\u591f\u76f8\u4e92\u8fde\u63a5\u3002 \u4e3b\u670d\u52a1\u5668\u548c\u4ece\u670d\u52a1\u5668\u5fc5\u987b\u4f7f\u7528\u76f8\u540c\u7684 MySQL \u7248\u672c\u3002 \u4ece\u670d\u52a1\u5668\u5fc5\u987b\u5177\u6709\u7528\u4e8e\u590d\u5236\u7684\u6743\u9650\u3002 \u6b65\u9aa4\uff1a \u5728\u4e3b\u670d\u52a1\u5668\u4e0a\u521b\u5efa\u590d\u5236\u7528\u6237\uff1a CREATE USER &#8216;repl_user&#8217;@&#8217;%&#8217; IDENTIFIED BY &#8216;strong_password&#8217;; GRANT REPLICATION SLAVE ON *.* TO &#8216;repl_user&#8217;@&#8217;%&#8217;; FLUSH PRIVILEGES; \u767b\u5f55\u540e\u590d\u5236 \u5728\u4e3b\u670d\u52a1\u5668\u4e0a\u542f\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u8bb0\u5f55\uff1a SET global binlog_format = &#8216;ROW&#8217;; SET global server_id = 1; # \u4e3a\u4e3b\u670d\u52a1\u5668\u5206\u914d\u552f\u4e00\u7684 ID \u767b\u5f55\u540e\u590d\u5236 \u83b7\u53d6\u4e3b\u670d\u52a1\u5668\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\u4fe1\u606f\uff1a SHOW MASTER STATUS; \u767b\u5f55\u540e\u590d\u5236 \u5728\u4ece\u670d\u52a1\u5668\u4e0a\u521b\u5efa\u590d\u5236\u901a\u9053\uff1a CREATE [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5148","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5148"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5148\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}