{"id":75720,"date":"2024-10-16T00:39:15","date_gmt":"2024-10-15T16:39:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/75720\/"},"modified":"2024-10-16T00:39:16","modified_gmt":"2024-10-15T16:39:16","slug":"mysql-communicationsexception%e7%95%b0%e5%b8%b8%e7%9a%84%e4%b8%89%e5%80%8b%e5%85%b8%e5%9e%8b%e5%a0%b4%e6%99%af%e5%8f%8a%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/75720\/","title":{"rendered":"MySQL-CommunicationsException\u7570\u5e38\u7684\u4e09\u500b\u5178\u578b\u5834\u666f\u53ca\u89e3\u6c7a\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"mysql-communicationsexception%e7%95%b0%e5%b8%b8%e7%9a%84%e4%b8%89%e5%80%8b%e5%85%b8%e5%9e%8b%e5%a0%b4%e6%99%af%e5%8f%8a%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%b3%95-KbMvGgHoqs\">MySQL-CommunicationsException\u7570\u5e38\u7684\u4e09\u500b\u5178\u578b\u5834\u666f\u53ca\u89e3\u6c7a\u65b9\u6cd5<\/h1>\n<p>\u5728\u4f7f\u7528MySQL\u6578\u64da\u5eab\u7684\u904e\u7a0b\u4e2d\uff0c\u958b\u767c\u8005\u7d93\u5e38\u6703\u9047\u5230\u5404\u7a2e\u7570\u5e38\u60c5\u6cc1\uff0c\u5176\u4e2d\u6700\u5e38\u898b\u7684\u4e4b\u4e00\u4fbf\u662fMySQL-CommunicationsException\u3002\u9019\u7a2e\u7570\u5e38\u901a\u5e38\u8207\u6578\u64da\u5eab\u7684\u9023\u63a5\u554f\u984c\u6709\u95dc\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u61c9\u7528\u7a0b\u5e8f\u7121\u6cd5\u6b63\u5e38\u904b\u884c\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u4e09\u500b\u5178\u578b\u7684MySQL-CommunicationsException\u7570\u5e38\u5834\u666f\u53ca\u5176\u89e3\u6c7a\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"%e5%a0%b4%e6%99%af%e4%b8%80%ef%bc%9a%e6%95%b8%e6%93%9a%e5%ba%ab%e6%9c%8d%e5%8b%99%e5%99%a8%e6%9c%aa%e5%95%9f%e5%8b%95-KbMvGgHoqs\">\u5834\u666f\u4e00\uff1a\u6578\u64da\u5eab\u670d\u52d9\u5668\u672a\u555f\u52d5<\/h2>\n<p>\u5728\u958b\u767c\u6216\u6e2c\u8a66\u74b0\u5883\u4e2d\uff0c\u6578\u64da\u5eab\u670d\u52d9\u5668\u53ef\u80fd\u56e0\u70ba\u67d0\u4e9b\u539f\u56e0\u672a\u555f\u52d5\uff0c\u9019\u6703\u5c0e\u81f4\u61c9\u7528\u7a0b\u5e8f\u7121\u6cd5\u9023\u63a5\u5230\u6578\u64da\u5eab\u3002\u7576\u61c9\u7528\u7a0b\u5e8f\u5617\u8a66\u9023\u63a5\u6642\uff0c\u4fbf\u6703\u62cb\u51faMySQL-CommunicationsException\u7570\u5e38\u3002<\/p>\n<h3 id=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%b3%95-KbMvGgHoqs\">\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n<ul>\n<li>\u6aa2\u67e5\u6578\u64da\u5eab\u670d\u52d9\u5668\u7684\u72c0\u614b\uff0c\u78ba\u4fdd\u5176\u5df2\u555f\u52d5\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5MySQL\u670d\u52d9\u7684\u72c0\u614b\uff1a<\/li>\n<pre><code>systemctl status mysql<\/code><\/pre>\n<li>\u5982\u679c\u670d\u52d9\u672a\u555f\u52d5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5\u5b83\uff1a<\/li>\n<pre><code>systemctl start mysql<\/code><\/pre>\n<\/ul>\n<h2 id=\"%e5%a0%b4%e6%99%af%e4%ba%8c%ef%bc%9a%e9%80%a3%e6%8e%a5%e5%8f%83%e6%95%b8%e9%85%8d%e7%bd%ae%e9%8c%af%e8%aa%a4-KbMvGgHoqs\">\u5834\u666f\u4e8c\uff1a\u9023\u63a5\u53c3\u6578\u914d\u7f6e\u932f\u8aa4<\/h2>\n<p>\u5728\u61c9\u7528\u7a0b\u5e8f\u4e2d\uff0c\u9023\u63a5\u5230MySQL\u6578\u64da\u5eab\u6642\u9700\u8981\u63d0\u4f9b\u6b63\u78ba\u7684\u9023\u63a5\u53c3\u6578\uff0c\u5305\u62ec\u4e3b\u6a5f\u540d\u3001\u7aef\u53e3\u865f\u3001\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002\u5982\u679c\u9019\u4e9b\u53c3\u6578\u914d\u7f6e\u932f\u8aa4\uff0c\u5247\u6703\u5c0e\u81f4MySQL-CommunicationsException\u7570\u5e38\u3002<\/p>\n<h3 id=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%b3%95-KbMvGgHoqs\">\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n<ul>\n<li>\u6aa2\u67e5\u61c9\u7528\u7a0b\u5e8f\u4e2d\u7684\u6578\u64da\u5eab\u9023\u63a5\u5b57\u7b26\u4e32\uff0c\u78ba\u4fdd\u6240\u6709\u53c3\u6578\u5747\u6b63\u78ba\u7121\u8aa4\u3002\u4f8b\u5982\uff1a<\/li>\n<pre><code>jdbc:mysql:\/\/localhost:3306\/mydatabase?user=myuser&amp;password=mypassword<\/code><\/pre>\n<li>\u78ba\u4fdd\u4e3b\u6a5f\u540d\u548c\u7aef\u53e3\u865f\u6b63\u78ba\uff0c\u7279\u5225\u662f\u5728\u4f7f\u7528Docker\u6216\u865b\u64ec\u6a5f\u6642\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u7684IP\u5730\u5740\u6216\u7aef\u53e3\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a0%b4%e6%99%af%e4%b8%89%ef%bc%9a%e9%98%b2%e7%81%ab%e7%89%86%e6%88%96%e7%b6%b2%e7%b5%a1%e5%95%8f%e9%a1%8c-KbMvGgHoqs\">\u5834\u666f\u4e09\uff1a\u9632\u706b\u7246\u6216\u7db2\u7d61\u554f\u984c<\/h2>\n<p>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u9632\u706b\u7246\u6216\u7db2\u7d61\u914d\u7f6e\u53ef\u80fd\u6703\u963b\u6b62\u61c9\u7528\u7a0b\u5e8f\u8207MySQL\u6578\u64da\u5eab\u4e4b\u9593\u7684\u901a\u4fe1\u3002\u9019\u7a2e\u60c5\u6cc1\u4e0b\uff0c\u7576\u61c9\u7528\u7a0b\u5e8f\u5617\u8a66\u9023\u63a5\u6642\uff0c\u4e5f\u6703\u51fa\u73feMySQL-CommunicationsException\u7570\u5e38\u3002<\/p>\n<h3 id=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%b3%95-KbMvGgHoqs\">\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n<ul>\n<li>\u6aa2\u67e5\u9632\u706b\u7246\u8a2d\u7f6e\uff0c\u78ba\u4fddMySQL\u7684\u7aef\u53e3\uff08\u9ed8\u8a8d\u70ba3306\uff09\u5df2\u958b\u653e\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\u9632\u706b\u7246\u898f\u5247\uff1a<\/li>\n<pre><code>sudo iptables -L<\/code><\/pre>\n<li>\u5982\u679c\u9632\u706b\u7246\u963b\u6b62\u4e86\u9023\u63a5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u958b\u653e\u7aef\u53e3\uff1a<\/li>\n<pre><code>sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT<\/code><\/pre>\n<li>\u6b64\u5916\uff0c\u6aa2\u67e5\u7db2\u7d61\u9023\u63a5\uff0c\u78ba\u4fdd\u61c9\u7528\u7a0b\u5e8f\u548c\u6578\u64da\u5eab\u670d\u52d9\u5668\u4e4b\u9593\u7684\u7db2\u7d61\u662f\u901a\u66a2\u7684\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-KbMvGgHoqs\">\u7e3d\u7d50<\/h2>\n<p>MySQL-CommunicationsException\u7570\u5e38\u901a\u5e38\u8207\u6578\u64da\u5eab\u7684\u9023\u63a5\u554f\u984c\u6709\u95dc\uff0c\u4e86\u89e3\u5176\u5178\u578b\u5834\u666f\u53ca\u89e3\u6c7a\u65b9\u6cd5\u5c0d\u65bc\u958b\u767c\u8005\u4f86\u8aaa\u81f3\u95dc\u91cd\u8981\u3002\u7121\u8ad6\u662f\u6578\u64da\u5eab\u670d\u52d9\u5668\u672a\u555f\u52d5\u3001\u9023\u63a5\u53c3\u6578\u914d\u7f6e\u932f\u8aa4\uff0c\u9084\u662f\u9632\u706b\u7246\u6216\u7db2\u7d61\u554f\u984c\uff0c\u901a\u904e\u6b63\u78ba\u7684\u6aa2\u67e5\u548c\u914d\u7f6e\uff0c\u90fd\u80fd\u6709\u6548\u89e3\u6c7a\u9019\u4e9b\u554f\u984c\u3002\u82e5\u60a8\u9700\u8981\u7a69\u5b9a\u7684\u6578\u64da\u5eab\u670d\u52d9\uff0c\u8003\u616e\u4f7f\u7528\u6211\u5011\u7684<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u89e3\u6c7a\u65b9\u6848\uff0c\u63d0\u4f9b\u9ad8\u6548\u7684\u6578\u64da\u5eab\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22MySQL-CommunicationsException\u7570\u5e38\u7684\u4e09\u500b\u5178\u578b\u5834\u666f\u53ca\u5176\u89e3\u6c7a\u65b9\u6cd5\uff0c\u52a9\u60a8\u5feb\u901f\u6392\u9664\u6545\u969c\uff0c\u63d0\u5347\u6578\u64da\u5eab\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-75720","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/75720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=75720"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/75720\/revisions"}],"predecessor-version":[{"id":75721,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/75720\/revisions\/75721"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=75720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=75720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=75720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}