{"id":5147,"date":"2024-11-14T08:39:01","date_gmt":"2024-11-14T00:39:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5147\/"},"modified":"2024-11-14T08:39:01","modified_gmt":"2024-11-14T00:39:01","slug":"mysql%e7%ab%af%e5%8f%a3%e9%87%8d%e5%a4%8d%e4%ba%86%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5147\/","title":{"rendered":"mysql\u7aef\u53e3\u91cd\u590d\u4e86\u600e\u4e48\u529e"},"content":{"rendered":"<blockquote><p>\n  mysql\u7aef\u53e3\u91cd\u590d\u95ee\u9898\u53ef\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u89e3\u51b3\uff1a\u68c0\u67e5\u7aef\u53e3\u4f7f\u7528\u60c5\u51b5\u3002\u505c\u6b62\u51b2\u7a81\u8fdb\u7a0b\u3002\u4fee\u6539mysql\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u7aef\u53e3\u53f7\u3002\u91cd\u542fmysql\u670d\u52a1\u3002\u8c03\u6574\u9632\u706b\u5899\u89c4\u5219\u4ee5\u5141\u8bb8\u65b0\u7aef\u53e3\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/22\/2024052217003325551.jpg\" class=\"aligncenter\" title=\"mysql\u7aef\u53e3\u91cd\u590d\u4e86\u600e\u4e48\u529e\u63d2\u56fe\" alt=\"mysql\u7aef\u53e3\u91cd\u590d\u4e86\u600e\u4e48\u529e\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u7aef\u53e3\u91cd\u590d\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u5f53 MySQL \u7aef\u53e3\u4e0e\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u6216\u670d\u52a1\u53d1\u751f\u51b2\u7a81\u65f6\uff0c\u4f1a\u5bfc\u81f4 MySQL \u65e0\u6cd5\u542f\u52a8\u6216\u8fd0\u884c\u5f02\u5e38\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u51b3 MySQL \u7aef\u53e3\u91cd\u590d\u95ee\u9898\u7684\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u68c0\u67e5\u7aef\u53e3\u4f7f\u7528\u60c5\u51b5<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u7aef\u53e3\u662f\u5426\u6b63\u5728\u4f7f\u7528\uff1a<\/p>\n<pre>sudo netstat -tulpn | grep &lt;port_number&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d \u662f MySQL \u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e3a 3306\uff09\u3002 <\/p>\n<p><strong>2. \u505c\u6b62\u51b2\u7a81\u8fdb\u7a0b<\/strong><\/p>\n<p>\u5982\u679c\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u6216\u670d\u52a1\u6b63\u5728\u4f7f\u7528\u8be5\u7aef\u53e3\uff0c\u8bf7\u505c\u6b62\u51b2\u7a81\u8fdb\u7a0b\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5f3a\u5236\u5173\u95ed\u8fdb\u7a0b\uff1a<\/p>\n<pre>sudo kill -9 &lt;process_id&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d \u662f\u51b2\u7a81\u8fdb\u7a0b\u7684\u8fdb\u7a0b ID\uff0c\u53ef\u4ee5\u4ece netstat \u547d\u4ee4\u7684\u8f93\u51fa\u4e2d\u83b7\u53d6\u3002 <\/p>\n<p><strong>3. \u4fee\u6539 MySQL \u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n<p>\u5982\u679c\u51b2\u7a81\u8fdb\u7a0b\u65e0\u6cd5\u505c\u6b62\uff0c\u6216\u8005\u60a8\u5e0c\u671b\u5c06 MySQL \u79fb\u52a8\u5230\u53e6\u4e00\u4e2a\u7aef\u53e3\uff0c\u8bf7\u7f16\u8f91 MySQL \u914d\u7f6e\u6587\u4ef6 (my.cnf)\u3002<\/p>\n<ul>\n<li>\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u884c\uff1a<\/li>\n<\/ul>\n<pre>port = 3306<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5c06 3306 \u66ff\u6362\u4e3a\u4e00\u4e2a\u672a\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u3002<\/li>\n<\/ul>\n<p><strong>4. \u91cd\u542f MySQL<\/strong><\/p>\n<p>\u4fdd\u5b58 MySQL \u914d\u7f6e\u6587\u4ef6\u5e76\u91cd\u542f MySQL \u670d\u52a1\uff1a<\/p>\n<pre>sudo service mysql restart<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u9632\u706b\u5899\u89c4\u5219<\/strong><\/p>\n<p>\u786e\u4fdd\u60a8\u7684\u9632\u706b\u5899\u5141\u8bb8\u901a\u8fc7\u65b0\u7684 MySQL \u7aef\u53e3\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5f00\u7aef\u53e3\uff1a<\/p>\n<pre>sudo ufw allow &lt;port_number&gt;\/tcp<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\u89c4\u5219\uff1a<\/p>\n<pre>sudo ufw reload<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u6b65\u9aa4\u5e94\u8be5\u53ef\u4ee5\u89e3\u51b3 MySQL \u7aef\u53e3\u91cd\u590d\u95ee\u9898\u3002\u5982\u679c\u60a8\u4ecd\u7136\u9047\u5230\u95ee\u9898\uff0c\u8bf7\u68c0\u67e5 MySQL \u9519\u8bef\u65e5\u5fd7\u4ee5\u83b7\u53d6\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7aef\u53e3\u91cd\u590d\u4e86\u600e\u4e48\u529e\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>mysql\u7aef\u53e3\u91cd\u590d\u95ee\u9898\u53ef\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u89e3\u51b3\uff1a\u68c0\u67e5\u7aef\u53e3\u4f7f\u7528\u60c5\u51b5\u3002\u505c\u6b62\u51b2\u7a81\u8fdb\u7a0b\u3002\u4fee\u6539mysql\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u7aef\u53e3\u53f7\u3002\u91cd\u542fmysql\u670d\u52a1\u3002\u8c03\u6574\u9632\u706b\u5899\u89c4\u5219\u4ee5\u5141\u8bb8\u65b0\u7aef\u53e3\u3002 MySQL \u7aef\u53e3\u91cd\u590d\u89e3\u51b3\u65b9\u6848 \u5f53 MySQL \u7aef\u53e3\u4e0e\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u6216\u670d\u52a1\u53d1\u751f\u51b2\u7a81\u65f6\uff0c\u4f1a\u5bfc\u81f4 MySQL \u65e0\u6cd5\u542f\u52a8\u6216\u8fd0\u884c\u5f02\u5e38\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u51b3 MySQL \u7aef\u53e3\u91cd\u590d\u95ee\u9898\u7684\u6b65\u9aa4\uff1a 1. \u68c0\u67e5\u7aef\u53e3\u4f7f\u7528\u60c5\u51b5 \u9996\u5148\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u7aef\u53e3\u662f\u5426\u6b63\u5728\u4f7f\u7528\uff1a sudo netstat -tulpn | grep &lt;port_number&gt; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d \u662f MySQL \u6b63\u5728\u4f7f\u7528\u7684\u7aef\u53e3\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e3a 3306\uff09\u3002 2. \u505c\u6b62\u51b2\u7a81\u8fdb\u7a0b \u5982\u679c\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u6216\u670d\u52a1\u6b63\u5728\u4f7f\u7528\u8be5\u7aef\u53e3\uff0c\u8bf7\u505c\u6b62\u51b2\u7a81\u8fdb\u7a0b\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5f3a\u5236\u5173\u95ed\u8fdb\u7a0b\uff1a sudo kill -9 &lt;process_id&gt; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d \u662f\u51b2\u7a81\u8fdb\u7a0b\u7684\u8fdb\u7a0b ID\uff0c\u53ef\u4ee5\u4ece netstat \u547d\u4ee4\u7684\u8f93\u51fa\u4e2d\u83b7\u53d6\u3002 3. \u4fee\u6539 MySQL \u914d\u7f6e\u6587\u4ef6 \u5982\u679c\u51b2\u7a81\u8fdb\u7a0b\u65e0\u6cd5\u505c\u6b62\uff0c\u6216\u8005\u60a8\u5e0c\u671b\u5c06 MySQL \u79fb\u52a8\u5230\u53e6\u4e00\u4e2a\u7aef\u53e3\uff0c\u8bf7\u7f16\u8f91 MySQL \u914d\u7f6e\u6587\u4ef6 (my.cnf)\u3002 \u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u884c\uff1a port = 3306 \u767b\u5f55\u540e\u590d\u5236 [&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-5147","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5147","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=5147"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5147\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}