{"id":5760,"date":"2024-11-14T12:09:42","date_gmt":"2024-11-14T04:09:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5760\/"},"modified":"2024-11-14T12:09:42","modified_gmt":"2024-11-14T04:09:42","slug":"sql%e6%95%b0%e6%8d%ae%e5%ba%93%e7%ab%af%e5%8f%a3%e5%8f%b7%e6%80%8e%e4%b9%88%e6%9f%a5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5760\/","title":{"rendered":"sql\u6570\u636e\u5e93\u7aef\u53e3\u53f7\u600e\u4e48\u67e5"},"content":{"rendered":"<blockquote><p>\n  \u8981\u67e5\u8be2 sql \u6570\u636e\u5e93\u7684\u7aef\u53e3\u53f7\uff1a\u8fde\u63a5\u6570\u636e\u5e93\u670d\u52a1\u5668\uff1b\u6267\u884c sql \u67e5\u8be2\u8bed\u53e5\uff1ashow variables like &#8216;port&#8217;\uff1b\u67e5\u627e\u540d\u4e3a port \u53d8\u91cf\u7684\u503c\uff0c\u8be5\u503c\u5373\u4e3a\u7aef\u53e3\u53f7\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/02\/2024060200541963435.jpg\" class=\"aligncenter\" title=\"sql\u6570\u636e\u5e93\u7aef\u53e3\u53f7\u600e\u4e48\u67e5\u63d2\u56fe\" alt=\"sql\u6570\u636e\u5e93\u7aef\u53e3\u53f7\u600e\u4e48\u67e5\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u6570\u636e\u5e93\u7aef\u53e3\u53f7\u67e5\u8be2\u65b9\u6cd5<\/strong><\/p>\n<p>\u8981\u67e5\u8be2 SQL \u6570\u636e\u5e93\u7684\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u91c7\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u8fde\u63a5\u6570\u636e\u5e93\u670d\u52a1\u5668<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u6570\u636e\u5e93\u5ba2\u6237\u7aef\u5de5\u5177\u6216\u547d\u4ee4\u884c\u8fde\u63a5\u5230\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002<\/li>\n<li>\n<p>\u4f8b\u5982\uff0c\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u5de5\u5177\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff1a<\/p>\n<pre>mysql -u username -p database_name<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p><strong>2. \u67e5\u8be2\u7aef\u53e3\u53f7<\/strong><\/p>\n<ul>\n<li>\n<p>\u8fde\u63a5\u540e\uff0c\u6267\u884c\u4ee5\u4e0b SQL \u67e5\u8be2\u8bed\u53e5\uff1a<\/p>\n<pre>SHOW VARIABLES LIKE 'port';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p><strong>3. \u67e5\u627e\u7aef\u53e3\u53f7<\/strong><\/p>\n<ul>\n<li>\u67e5\u8be2\u7ed3\u679c\u5c06\u663e\u793a\u4e00\u4e2a\u540d\u4e3a port \u7684\u53d8\u91cf\u3002\u53d8\u91cf\u7684\u503c\u5c31\u662f\u6570\u636e\u5e93\u670d\u52a1\u5668\u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>mysql&gt; SHOW VARIABLES LIKE 'port';\n+---------------+----------+\n| Variable_name | Value    |\n+---------------+----------+\n| port          | 3306     |\n+---------------+----------+\n1 row in set (0.001 sec)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u672c\u4f8b\u4e2d\uff0c\u6570\u636e\u5e93\u670d\u52a1\u5668\u6b63\u5728\u4f7f\u7528\u7aef\u53e3\u53f7 <strong>3306<\/strong>\u3002<\/p>\n<p><strong>\u5176\u4ed6\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u9664\u4e86\u4f7f\u7528 SQL \u67e5\u8be2\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u67e5\u8be2\u7aef\u53e3\u53f7\uff1a<\/p>\n<ul>\n<li>\n<p><strong>\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\uff1a<\/strong><\/p>\n<ul>\n<li>Linux\/macOS\uff1anetstat -an | grep :3306<\/li>\n<li>Windows\uff1anetstat -ano | findstr 3306<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6\uff1a<\/strong><\/p>\n<ul>\n<li>MySQL\uff1a\/etc\/\/my.cnf<\/li>\n<li>PostgreSQL\uff1a\/var\/lib\/postgresql\/data\/postgresql.conf<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u6570\u636e\u5e93\u7aef\u53e3\u53f7\u600e\u4e48\u67e5\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>\u8981\u67e5\u8be2 sql \u6570\u636e\u5e93\u7684\u7aef\u53e3\u53f7\uff1a\u8fde\u63a5\u6570\u636e\u5e93\u670d\u52a1\u5668\uff1b\u6267\u884c sql \u67e5\u8be2\u8bed\u53e5\uff1ashow variables like &#8216;port&#8217;\uff1b\u67e5\u627e\u540d\u4e3a port \u53d8\u91cf\u7684\u503c\uff0c\u8be5\u503c\u5373\u4e3a\u7aef\u53e3\u53f7\u3002 SQL \u6570\u636e\u5e93\u7aef\u53e3\u53f7\u67e5\u8be2\u65b9\u6cd5 \u8981\u67e5\u8be2 SQL \u6570\u636e\u5e93\u7684\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u91c7\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u8fde\u63a5\u6570\u636e\u5e93\u670d\u52a1\u5668 \u4f7f\u7528\u6570\u636e\u5e93\u5ba2\u6237\u7aef\u5de5\u5177\u6216\u547d\u4ee4\u884c\u8fde\u63a5\u5230\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002 \u4f8b\u5982\uff0c\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u5de5\u5177\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff1a mysql -u username -p database_name \u767b\u5f55\u540e\u590d\u5236 2. \u67e5\u8be2\u7aef\u53e3\u53f7 \u8fde\u63a5\u540e\uff0c\u6267\u884c\u4ee5\u4e0b SQL \u67e5\u8be2\u8bed\u53e5\uff1a SHOW VARIABLES LIKE &#8216;port&#8217;; \u767b\u5f55\u540e\u590d\u5236 3. \u67e5\u627e\u7aef\u53e3\u53f7 \u67e5\u8be2\u7ed3\u679c\u5c06\u663e\u793a\u4e00\u4e2a\u540d\u4e3a port \u7684\u53d8\u91cf\u3002\u53d8\u91cf\u7684\u503c\u5c31\u662f\u6570\u636e\u5e93\u670d\u52a1\u5668\u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u3002 \u793a\u4f8b\uff1a mysql&gt; SHOW VARIABLES LIKE &#8216;port&#8217;; +&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+ | Variable_name | Value [&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-5760","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5760","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=5760"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5760\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}