{"id":6195,"date":"2024-11-14T10:15:27","date_gmt":"2024-11-14T02:15:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6195\/"},"modified":"2024-11-14T10:15:27","modified_gmt":"2024-11-14T02:15:27","slug":"mysql%e7%ab%af%e5%8f%a3%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6195\/","title":{"rendered":"mysql\u7aef\u53e3\u5982\u4f55\u67e5\u770b"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u901a\u8fc7\u4e09\u79cd\u65b9\u6cd5\u67e5\u770b mysql \u7aef\u53e3\uff1a\u4f7f\u7528 show variables \u547d\u4ee4\u67e5\u770b port \u53d8\u91cf\uff1b\u68c0\u67e5 mysql \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 port = \u884c\uff1b\u4f7f\u7528 netstat \u547d\u4ee4 grep mysql\uff0c\u67e5\u770b\u672c\u5730\u5730\u5740\u5b57\u6bb5\u4e2d\u7684\u7aef\u53e3\u53f7\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/14\/2024061406062396011.jpg\" class=\"aligncenter\" title=\"mysql\u7aef\u53e3\u5982\u4f55\u67e5\u770b\u63d2\u56fe\" alt=\"mysql\u7aef\u53e3\u5982\u4f55\u67e5\u770b\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b MySQL \u7aef\u53e3<\/strong><\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u4f7f\u7528 SHOW VARIABLES \u547d\u4ee4<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7 MySQL \u547d\u4ee4\u884c\u754c\u9762\u6216\u5ba2\u6237\u7aef\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>SHOW VARIABLES LIKE '%port%';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06\u663e\u793a\u4e00\u4e2a\u5305\u542b\u53d8\u91cf\u540d\u79f0\u548c\u503c\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b port \u53d8\u91cf\uff0c\u8be5\u53d8\u91cf\u8868\u793a MySQL \u6b63\u5728\u76d1\u542c\u7684\u7aef\u53e3\u3002<\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n<p>MySQL \u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e \/etc\/\/my.cnf\uff08Linux\uff09\u6216 \/usr\/local\/etc\/my.cnf\uff08macOS\uff09\u3002\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u641c\u7d22\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre>port = &lt;port_number&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d \u662f MySQL \u6b63\u5728\u76d1\u542c\u7684\u7aef\u53e3\u3002 <\/p>\n<p><strong>\u65b9\u6cd5 3\uff1a\u4f7f\u7528 netstat \u547d\u4ee4<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u754c\u9762\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u6253\u5f00\u7684\u7aef\u53e3\uff1a<\/p>\n<pre>netstat -ant | grep mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u663e\u793a MySQL \u6b63\u5728\u76d1\u542c\u7684 TCP \u7aef\u53e3\u7684\u5217\u8868\u3002\u7aef\u53e3\u53f7\u901a\u5e38\u5217\u5728 \u672c\u5730\u5730\u5740 \u5b57\u6bb5\u4e2d\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>tcp 0 0 127.0.0.1:3306 127.0.0.1:54534 ESTABLISHED<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d 3306 \u662f MySQL \u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7aef\u53e3\u5982\u4f55\u67e5\u770b\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>\u53ef\u901a\u8fc7\u4e09\u79cd\u65b9\u6cd5\u67e5\u770b mysql \u7aef\u53e3\uff1a\u4f7f\u7528 show variables \u547d\u4ee4\u67e5\u770b port \u53d8\u91cf\uff1b\u68c0\u67e5 mysql \u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 port = \u884c\uff1b\u4f7f\u7528 netstat \u547d\u4ee4 grep mysql\uff0c\u67e5\u770b\u672c\u5730\u5730\u5740\u5b57\u6bb5\u4e2d\u7684\u7aef\u53e3\u53f7\u3002 \u5982\u4f55\u67e5\u770b MySQL \u7aef\u53e3 \u65b9\u6cd5 1\uff1a\u4f7f\u7528 SHOW VARIABLES \u547d\u4ee4 \u53ef\u4ee5\u901a\u8fc7 MySQL \u547d\u4ee4\u884c\u754c\u9762\u6216\u5ba2\u6237\u7aef\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a SHOW VARIABLES LIKE &#8216;%port%&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5c06\u663e\u793a\u4e00\u4e2a\u5305\u542b\u53d8\u91cf\u540d\u79f0\u548c\u503c\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b port \u53d8\u91cf\uff0c\u8be5\u53d8\u91cf\u8868\u793a MySQL \u6b63\u5728\u76d1\u542c\u7684\u7aef\u53e3\u3002 \u65b9\u6cd5 2\uff1a\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6 MySQL \u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e \/etc\/\/my.cnf\uff08Linux\uff09\u6216 \/usr\/local\/etc\/my.cnf\uff08macOS\uff09\u3002\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u641c\u7d22\u4ee5\u4e0b\u884c\uff1a port = &lt;port_number&gt; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d \u662f MySQL \u6b63\u5728\u76d1\u542c\u7684\u7aef\u53e3\u3002 \u65b9\u6cd5 3\uff1a\u4f7f\u7528 netstat [&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-6195","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6195","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=6195"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6195\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}