{"id":22611,"date":"2025-12-01T00:00:55","date_gmt":"2025-11-30T16:00:55","guid":{"rendered":"https:\/\/beyond-shenzhen.cn\/?post_type=blog&#038;p=22611"},"modified":"2026-04-16T11:15:14","modified_gmt":"2026-04-16T03:15:14","slug":"mysql-port-danger","status":"publish","type":"blog","link":"https:\/\/beyond-shenzhen.cn\/zh\/blog\/mysql-port-danger\/","title":{"rendered":"\u3010\u5371\u9669\u3011\u8bf7\u52ff\u5c06 MySQL 3306 \u7aef\u53e3\u5bf9\u5916\u5f00\u653e\uff01\uff01"},"content":{"rendered":"<p>\u4f5c\u4e3a\u7f51\u7ad9\u6216\u670d\u52a1\u5668\u7ba1\u7406\u5458\uff0c\u4e00\u4e9b\u770b\u4f3c\u4e0d\u8d77\u773c\u7684\u8bbe\u7f6e\uff0c\u53ef\u80fd\u4f1a\u5e26\u6765\u4e25\u91cd\u7684\u5b89\u5168\u98ce\u9669\uff0c\u800c\u7ba1\u7406\u5458\u672c\u4eba\u5f80\u5f80\u5e76\u672a\u5bdf\u89c9\u3002<\/p>\n<p>\u5f88\u591a\u4eba\u4f1a\u60f3\uff1a\u201c\u7f51\u7ad9\u4e0d\u662f\u6b63\u5e38\u8fd0\u884c\u5417\uff1f\u201d\u3001\u201c\u6709\u5bc6\u7801\u5c31\u5b89\u5168\u4e86\u5427\uff1f\u201d<\/p>\n<p>\u4e8b\u5b9e\u4e0a\uff0c\u8fd9\u79cd\u60f3\u6cd5\u5f80\u5f80\u4f1a\u57cb\u4e0b\u9690\u60a3\u3002<\/p>\n<h2>\u5c063306\u7aef\u53e3\u5bf9\u5916\u5f00\u653e\uff0c\u4f1a\u6709\u4ec0\u4e48\u540e\u679c\uff1f<\/h2>\n<p>\u8fd9\u7b49\u540c\u4e8e\u628aMySQL \/ MariaDB\u6570\u636e\u5e93\u76f4\u63a5\u66b4\u9732\u5728\u4e92\u8054\u7f51\u4e0a\uff0c\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u5c1d\u8bd5\u8bbf\u95ee\u3002<\/p>\n<p>\u800c\u6570\u636e\u5e93\u4e2d\u5f80\u5f80\u4fdd\u5b58\u7740\u6700\u654f\u611f\u7684\u4f01\u4e1a\u4fe1\u606f\u548c\u5ba2\u6237\u6570\u636e\u3002<\/p>\n<p>\u5373\u4f7f\u8bbe\u7f6e\u4e86\u5bc6\u7801\uff0c\u4e5f\u53ef\u80fd\u88ab\u66b4\u529b\u7834\u89e3\u3002<\/p>\n<p>\u516c\u5f00 3306 \u7aef\u53e3\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u4e3a\u653b\u51fb\u8005\u63d0\u4f9b\u4e86\u76f4\u63a5\u5165\u53e3\u3002<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 72px;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 25%; height: 24px; background-color: #2f8031;\" colspan=\"2\"><span style=\"color: #ffffff;\">\u6b63\u5e38\u8bbe\u7f6e<\/span><\/td>\n<td style=\"width: 25%; height: 24px; background-color: #8f2828;\" colspan=\"2\"><span style=\"color: #ffffff;\">\u5371\u9669\u8bbe\u7f6e<\/span><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 25%; height: 24px; background-color: #c6f5c7;\">Web\u670d\u52a1\u5668<\/td>\n<td style=\"width: 25%; height: 24px;\"><span style=\"background-color: #f3f3f3; padding: 3px 3px;\">localhost<\/span>\u00a0\u6216\u00a0<span style=\"background-color: #f3f3f3; padding: 3px 3px;\">127.0.0.1<\/span> \u76843306\u7aef\u53e3<\/td>\n<td style=\"width: 25%; height: 24px; background-color: #ffd6d6;\">Web\u670d\u52a1\u5668<\/td>\n<td style=\"width: 25%; height: 24px;\"><span style=\"background-color: #f3f3f3; padding: 3px 3px;\">0.0.0.0<\/span> \u6216\u670d\u52a1\u5668\u516c\u7f51IP\u76843306\u7aef\u53e3<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 25%; height: 24px; background-color: #c6f5c7;\">\u5916\u90e8\u8fde\u63a5<\/td>\n<td style=\"width: 25%; height: 24px;\">\u88ab\u5b8c\u5168\u963b\u65ad\uff0c\u65e0\u6cd5\u8bbf\u95ee<\/td>\n<td style=\"width: 25%; height: 24px; background-color: #ffd6d6;\">\u5916\u90e8\u8fde\u63a5<\/td>\n<td style=\"width: 25%; height: 24px;\">\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u8bbf\u95ee<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>* 127.0.0.1 \u662f\u4fdd\u7559\u7ed9\u8ba1\u7b97\u673a\u672c\u673a\u4f7f\u7528\u7684\u4e13\u7528 IP \u5730\u5740\uff0c\u56fa\u5b9a\u7528\u4e8e\u6307\u5411\u201c\u672c\u673a\u201d\u3002<br \/>\n\u6362\u53e5\u8bdd\u8bf4\uff0c\u8bbe\u7f6e\u4e3a 127.0.0.1 \u65f6\uff0c\u53ea\u6709\u670d\u52a1\u5668\u81ea\u8eab\u624d\u80fd\u8bbf\u95ee\u8be5\u670d\u52a1\uff0c\u5916\u90e8\u8bbe\u5907\u65e0\u6cd5\u8fde\u63a5\u3002<\/p>\n<h2>\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u5371\u9669\u8bbe\u7f6e\uff1f<\/h2>\n<p>\u5371\u9669\u8bbe\u7f6e\u4e0d\u4ec5\u6e90\u4e8e\u77e5\u8bc6\u4e0d\u8db3\uff0c\u4e5f\u5bb9\u6613\u5728\u7279\u5b9a\u5de5\u4f5c\u60c5\u51b5\u4e0b\u53d1\u751f\u3002<\/p>\n<p>\u5728\u7279\u5b9a\u5de5\u4f5c\u60c5\u51b5\u4e0b\uff0c\u5f88\u591a\u4eba\u4f1a\u62b1\u7740\uff1a\u201c\u53ea\u662f\u4e34\u65f6\u7528\u4e00\u4e0b\u201d\u3001\u201c\u53cd\u6b63\u73b0\u5728\u80fd\u6b63\u5e38\u8fd0\u884c\u201d\u7684\u4fa5\u5e78\u5fc3\u7406\uff0c\u8fdb\u884c\u5371\u9669\u8bbe\u7f6e\u3002<\/p>\n<p>\u901a\u5e38\uff0c\u51fa\u73b0\u5371\u9669\u8bbe\u7f6e\u53ef\u5f52\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\u539f\u56e0\u3002<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 96px;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 32.9146%; height: 24px; background-color: #ffd6d6;\">\u521d\u59cb\u8bbe\u7f6e\u6cbf\u7528\u793a\u4f8b<\/td>\n<td style=\"width: 67.0854%; height: 24px;\">\u76f4\u63a5\u4f7f\u7528\u6559\u7a0b\u6216\u793a\u4f8b\u7f51\u7ad9\u7684\u9ed8\u8ba4\u914d\u7f6e\uff08\u5982 bind-address = 0.0.0.0\uff09\uff0c\u672a\u4f5c\u8c03\u6574\u5c31\u90e8\u7f72\u5230\u6b63\u5f0f\u73af\u5883\u3002<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 32.9146%; height: 24px; background-color: #ffd6d6;\">\u5bf9\u63a5\u5916\u90e8\u670d\u52a1\u540e\u5fd8\u8bb0\u5173\u95ed<\/td>\n<td style=\"width: 67.0854%; height: 24px;\">\u4e3a\u4e86\u4e34\u65f6\u8ba9\u5916\u90e8\u5de5\u5177\u6216\u5907\u4efd\u670d\u52a1\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u5f00\u653e\u4e86\u8fde\u63a5\uff0c\u4f46\u64cd\u4f5c\u5b8c\u6210\u540e\u5fd8\u8bb0\u5173\u95ed\u3002<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 32.9146%; height: 24px; background-color: #ffd6d6;\">\u5de5\u4f5c\u4ea4\u63a5\u758f\u6f0f<\/td>\n<td style=\"width: 67.0854%; height: 24px;\">\u524d\u4efb\u4eba\u5458\u4e3a\u201c\u4e00\u65f6\u5e94\u6025\u201d\u4fee\u6539\u8bbe\u7f6e\uff0c\u5374\u672a\u8bb0\u5f55\u5728\u4ea4\u63a5\u6587\u6863\u4e2d\uff0c\u540e\u7eed\u88ab\u8bef\u5f53\u4f5c\u5e38\u89c4\u914d\u7f6e\u6cbf\u7528\u3002<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 32.9146%; height: 24px; background-color: #ffd6d6;\">\u5916\u5305\u5382\u5546\u914d\u7f6e\u9519\u8bef<\/td>\n<td style=\"width: 67.0854%; height: 24px;\">\u7cfb\u7edf\u5f00\u53d1\u5546\u8bef\u5c06\u6d4b\u8bd5\u73af\u5883\u7684\u8bbe\u7f6e\u5e94\u7528\u5230\u6b63\u5f0f\u73af\u5883\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u5bf9\u5916\u5f00\u653e3306\u7aef\u53e3\u7684\u4e25\u91cd\u540e\u679c<\/h2>\n<p>\u5c063306\u7aef\u53e3\u66b4\u9732\u5728\u4e92\u8054\u7f51\u4e0a\uff0c\u4e0d\u53ea\u662f\u7b80\u5355\u7684\u8bbe\u7f6e\u5931\u8bef\u95ee\u9898\uff0c\u8fd8\u5c06\u7ed9\u4f01\u4e1a\u4e1a\u52a1\u5e26\u6765\u91cd\u5927\u7684\u5b89\u5168\u9690\u60a3\u3002<\/p>\n<p>\u5177\u4f53\u5371\u9669\u5305\u62ec\uff1a<\/p>\n<h3>\u2460 \u4e3a\u653b\u51fb\u8005\u6253\u5f00\u6570\u636e\u5e93\u5165\u53e3<\/h3>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\">\r\n<span style=\"line-height: 26px;\">-- \u653b\u51fb\u8005\u53ef\u4ee5\u76f4\u63a5\u8fde\u63a5\u5e76\u64cd\u4f5c\u4f60\u7684\u6570\u636e\u5e93\r\n<span style=\"color: #ffff00;\">DROP TABLE users;\r\nDELETE FROM orders;<\/span><\/span>\r\n<\/code><\/pre>\n<h3>\u2461 \u4fe1\u606f\u6cc4\u9732\u98ce\u9669<\/h3>\n<p>\u3007 \u5ba2\u6237\u4fe1\u606f\uff08\u59d3\u540d\u30fb\u90ae\u7bb1\u7b49\uff09<br \/>\n\u3007 \u5bc6\u7801\uff08\u5373\u4fbf\u7ecf\u8fc7\u54c8\u5e0c\u5316\u5904\u7406\u4ecd\u53ef\u80fd\u88ab\u7834\u89e3\uff09<br \/>\n\u3007 \u8ba2\u5355\u8bb0\u5f55\u53ca\u5176\u4ed6\u673a\u5bc6\u6570\u636e<\/p>\n<h3>\u2462 \u7f51\u7ad9\u762b\u75ea<\/h3>\n<p>\u4e00\u65e6\u6570\u636e\u5e93\u88ab\u5220\u9664\uff0c\u7f51\u7ad9\u5c06\u5b8c\u5168\u505c\u6b62\u8fd0\u884c\u3002\uff08\u7f51\u7ad9\u9875\u9762\u4e5f\u65e0\u6cd5\u663e\u793a\uff09<\/p>\n<h3>\u2463 \u670d\u52a1\u5668\u88ab\u52ab\u6301<\/h3>\n<p>\u653b\u51fb\u8005\u53ef\u80fd\u901a\u8fc7\u6570\u636e\u5e93\u5165\u4fb5\u6574\u4e2a\u7cfb\u7edf\uff0c\u5c06\u670d\u52a1\u5668\u7528\u4f5c\u53d1\u52a8\u653b\u51fb\u7684\u8df3\u677f\u3002\uff08\u5982\u4f20\u64ad\u52d2\u7d22\u75c5\u6bd2\u7b49\uff09<\/p>\n<h2>\u7acb\u5373\u6392\u67e53306\u7aef\u53e3\u662f\u5426\u66b4\u9732<\/h2>\n<p>\u53ef\u4ee5\u901a\u8fc7\u5728\u7ebf\u5de5\u5177\u6216\u547d\u4ee4\u884c\uff0c\u5feb\u901f\u68c0\u6d4bMySQL\u76843306\u7aef\u53e3\u662f\u5426\u5bf9\u5916\u516c\u5f00\u3002<\/p>\n<h3>\u2460 \u4f7f\u7528\u5728\u7ebf\u5de5\u5177<\/h3>\n<p>\u8bbf\u95ee\u5728\u7ebf\u7aef\u53e3\u68c0\u6d4b\u7f51\u7ad9\uff0c\u8f93\u5165\u670d\u52a1\u5668IP\u5730\u5740\uff0c\u67e5\u8be23306\u7aef\u53e3\u662f\u5426\u663e\u793a\u4e3a&#8221;OPEN&#8221;\u3002<\/p>\n<p>\u3007 ping.eu<br \/>\n<a href=\"https:\/\/ping.eu\/port-chk\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/ping.eu\/port-chk<\/a><\/p>\n<p>\u3007 you get signal<br \/>\n<a href=\"https:\/\/www.yougetsignal.com\/tools\/open-ports\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/www.yougetsignal.com\/tools\/open-ports<\/a><\/p>\n<h3>\u2461 \u901a\u8fc7\u670d\u52a1\u5668\u547d\u4ee4\u884c\u68c0\u6d4b<\/h3>\n<p>\u5728\u670d\u52a1\u5668\u5185\u90e8\u5c1d\u8bd5\u8fde\u63a5 3306 \u7aef\u53e3\uff0c\u5982\u679c\u8fde\u63a5\u6210\u529f\uff0c\u8bf4\u660e\u7aef\u53e3\u53ef\u80fd\u5bf9\u5916\u66b4\u9732\uff0c\u9700\u8981\u7acb\u5373\u5904\u7406\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; background: #282c34; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px;\"><span style=\"color: #ffff00;\">telnet [\u670d\u52a1\u5668IP] 3306<\/span>\r\n<\/code><\/pre>\n<h2>MySQL 3306\u7aef\u53e3\u6b63\u786e\u8bbe\u7f6e\u6307\u5357<\/h2>\n<p>\u672c\u6307\u5357\u5047\u8bbeWeb\u670d\u52a1\u5668\u548c\u6570\u636e\u5e93\u90e8\u7f72\u5728\u540c\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\uff0c\u4ecb\u7ecd3306\u7aef\u53e3\u7684\u5b89\u5168\u8bbe\u7f6e\u65b9\u6cd5\u3002<\/p>\n<p><span style=\"color: #ff0000;\">* \u91cd\u8981\u63d0\u793a\uff1a \u5728\u6b63\u5f0f\u73af\u5883\u64cd\u4f5c\u524d\uff0c\u8bf7\u52a1\u5fc5\u5907\u4efd\u6570\u636e\u5e93\uff0c\u4ee5\u9632\u8bbe\u7f6e\u51fa\u9519\u5bfc\u81f4\u6570\u636e\u4e22\u5931\u3002<\/span><\/p>\n<h3>\u2460 \u67e5\u770b\u5f53\u524d\u8bbe\u7f6e<\/h3>\n<p>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5MySQL\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684bind-address\u8bbe\u7f6e\u3002<\/p>\n<p>\u5982\u679c\u663e\u793a<span style=\"background-color: #f3f3f3;\">0.0.0.0<\/span>\u6216\u670d\u52a1\u5668\u516c\u7f51IP\uff0c\u5219\u8bf4\u660e\u7aef\u53e3\u5bf9\u5916\u5f00\u653e\uff0c\u9700\u8981\u7acb\u5373\u4fee\u6b63\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u68c0\u67e5 MySQL \u8bbe\u7f6e\u6587\u4ef6 * \u786e\u8ba4 bind-address \u8bbe\u7f6e\r\n<span style=\"color: #d1edff;\">sudo grep -r \"bind-address\" \/etc\/mysql\/<\/span>\r\n\r\n# \u67e5\u770b MySQL \u5f53\u524d\u76d1\u542c\u7684\u7f51\u7edc\u63a5\u53e3\r\n<span style=\"color: #d1edff;\">sudo netstat -tlnp | grep mysql<\/span>\r\n<\/code><\/pre>\n<blockquote><p>[mysqld]<br \/>\n<span style=\"color: #2f8031;\">bind-address = 127.0.0.1\u3000# \u5b89\u5168\uff01<\/span><br \/>\n<span style=\"color: #8f2828;\"># bind-address = 0.0.0.0\u3000# \u5371\u9669\uff01<\/span><\/p><\/blockquote>\n<h3>\u2461 \u7f16\u8f91\u8bbe\u7f6e\u6587\u4ef6<\/h3>\n<p>\u901a\u8fc7\u4fee\u6539 MySQL \u914d\u7f6e\u6587\u4ef6\uff0c\u4ec5\u5141\u8bb8\u672c\u673a\u8fde\u63a5\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u7f16\u8f91\u8bbe\u7f6e\u6587\u4ef6\uff08\u6587\u4ef6\u8def\u5f84\u6839\u636e\u73af\u5883\u53ef\u80fd\u4e0d\u540c\uff09\r\n<span style=\"color: #d1edff;\">sudo nano \/etc\/mysql\/mysql.conf.d\/mysqld.cnf<\/span>\r\n\r\n# \u6216\r\n<span style=\"color: #d1edff;\">sudo nano \/etc\/mysql\/my.cnf<\/span>\r\n<\/code><\/pre>\n<p>\u5728MySQL\u914d\u7f6e\u6587\u4ef6\u4e2d\u627e\u5230\u5e76\u4fee\u6539\u4ee5\u4e0b\u5185\u5bb9\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u5b89\u5168\u8bbe\u7f6e\uff08\u786e\u8ba4\u6216\u4fee\u6539\u4e3a\u5982\u4e0b\uff09\r\n<span style=\"color: #c6f5c7;\">bind-address = 127.0.0.1\r\n\r\n<\/span>\r\n\r\n<span style=\"color: #ffd6d6;\"># \u5371\u9669\u8bbe\u7f6e\uff08\u82e5\u5b58\u5728\u9700\u7acb\u5373\u4fee\u6539\uff09\r\n# bind-address = 0.0.0.0\r\n# bind-address = \u670d\u52a1\u5668\u516c\u7f51IP <\/span>\r\n<\/code><\/pre>\n<h3>\u2462 \u4f7f\u8bbe\u7f6e\u751f\u6548<\/h3>\n<p>\u4fdd\u5b58\u8bbe\u7f6e\u6587\u4ef6\u540e\uff0c\u9700\u8981\u91cd\u542fMySQL\u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u53ef\u9009\uff1a\u68c0\u67e5\u8bbe\u7f6e\u6587\u4ef6\u8bed\u6cd5\uff08\u63a8\u8350\uff09\r\n<span style=\"color: #d1edff;\">sudo mysqld --validate-config<\/span>\r\n\r\n# \u91cd\u542f MySQL \u670d\u52a1\r\n<span style=\"color: #d1edff;\">sudo systemctl restart mysql\r\n\r\n<\/span># \u6216\uff08\u6839\u636e\u7cfb\u7edf\u4e0d\u540c\uff09<span style=\"color: #d1edff;\">\r\nsudo service mysql restart\r\n<\/span>\r\n# \u68c0\u67e5\u670d\u52a1\u72b6\u6001\u662f\u5426\u6b63\u5e38\r\n<span style=\"color: #d1edff;\">sudo systemctl status mysql<\/span>\r\n<\/code><\/pre>\n<h3>\u2463 \u786e\u8ba4\u8bbe\u7f6e\u662f\u5426\u751f\u6548<\/h3>\n<p>\u91cd\u542f\u540e\uff0c\u68c0\u67e5MySQL\u662f\u5426\u6309\u65b0\u7684\u914d\u7f6e\u8fd0\u884c\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u67e5\u770b MySQL \u662f\u5426\u4ec5\u76d1\u542c\u672c\u673a\u5730\u5740\r\n<span style=\"color: #d1edff;\">sudo netstat -tlnp | grep mysql\r\n\r\n<\/span>\r\n\r\n<span style=\"color: #c6f5c7;\"># \u9884\u671f\u8f93\u51fa\u793a\u4f8b\uff1a\r\n# tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      -\r\n\r\n<span style=\"color: #ffffff;\"># \u4ece\u8fdb\u7a0b\u4fe1\u606f\u4e2d\u518d\u6b21\u786e\u8ba4<\/span>\r\nsudo ps aux | grep mysql\r\n<\/span>\r\n<\/code><\/pre>\n<p>\u5982\u679c\u7ed3\u679c\u663e\u793a <span style=\"background-color: #f3f3f3;\">127.0.0.1:3306<\/span>\uff0c\u8bf4\u660e\u914d\u7f6e\u5df2\u6210\u529f\u751f\u6548\uff0c\u6570\u636e\u5e93\u5df2\u5904\u4e8e\u4e0d\u53ef\u4ece\u5916\u90e8\u8bbf\u95ee\u7684\u5b89\u5168\u72b6\u6001\u3002<\/p>\n<h3>\u5982\u679c\u51fa\u73b0\u95ee\u9898\u8be5\u600e\u4e48\u529e\uff1f<\/h3>\n<p>\u82e5\u5728\u4fee\u6539MySQL\u8bbe\u7f6e\u540e\uff0c\u7f51\u7ad9\u65e0\u6cd5\u8fde\u63a5\u6570\u636e\u5e93\uff0c\u53ef\u6309\u4ee5\u4e0b\u6b65\u9aa4\u6392\u67e5\u3002<\/p>\n<ol>\n<li>\u68c0\u67e5\u8bbe\u7f6e\u6587\u4ef6\u8bed\u6cd5\uff1a\u786e\u8ba4\u6ca1\u6709\u62fc\u5199\u9519\u8bef\u6216\u591a\u4f59\u5b57\u7b26\u3002<\/li>\n<li>\u68c0\u67e5Web\u5e94\u7528\u7684\u6570\u636e\u5e93\u8fde\u63a5\u8bbe\u7f6e\uff1a\u786e\u4fdd\u8fde\u63a5\u5730\u5740\u4e3a <span style=\"background-color: #f3f3f3;\">localhost<\/span> \u6216 <span style=\"background-color: #f3f3f3;\">127.0.0.1<\/span>\u3002<\/li>\n<li>\u67e5\u770bMySQL\u9519\u8bef\u65e5\u5fd7\uff1a\u4e86\u89e3\u5177\u4f53\u9519\u8bef\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u67e5\u770b MySQL \u9519\u8bef\u65e5\u5fd7\r\nsudo tail -f \/var\/log\/mysql\/error.log \r\n<\/code><\/pre>\n<h2>\u5728\u8fdc\u7a0b\u73af\u5883\u4e2d\u8fde\u63a5\u6570\u636e\u5e93\u7684\u6b63\u786e\u65b9\u5f0f<\/h2>\n<p>\u82e5\u9700\u8981\u4ece\u8fdc\u7a0b\u73af\u5883\u8fde\u63a5\u6570\u636e\u5e93\uff0c\u5fc5\u987b\u540c\u65f6\u6ee1\u8db3\u4e24\u70b9\u3002\u201c\u9650\u5236\u5141\u8bb8\u8bbf\u95ee\u7684\u56fa\u5b9aIP\u5730\u5740\uff08\u53ef\u4fe1\u6765\u6e90\uff09\u201d\u548c\u201c\u901a\u8fc7SSH\uff08SSH\u96a7\u9053\uff09\u8fdb\u884c\u8fde\u63a5\u201d\uff0c\u8fd9\u4e24\u8005\u7f3a\u4e00\u4e0d\u53ef\u3002<\/p>\n<p>\u5982\u679c\u672a\u6307\u5b9a\u53ef\u4fe1\u4efb\u7684\u56fa\u5b9aIP\u5c31\u76f4\u63a5\u5f00\u653eSSH\u7aef\u53e3\uff0c\u5c06\u4f1a\u5e26\u6765\u65b0\u7684\u5b89\u5168\u98ce\u9669\u3002<\/p>\n<h3>\u2460 \u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u7aef\u6307\u5b9a\u56fa\u5b9aIP<\/h3>\n<p>\u3007 \u9002\u7528\u4e8eRHEL \/ AlmaLinux\uff08\u4f7f\u7528firewalld\uff09<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u4ec5\u5141\u8bb8\u6765\u81ea\u201c\u53ef\u4fe1\u56fa\u5b9aIP\u201d\u7684SSH\u8fde\u63a5\r\n<span style=\"color: #d1edff;\">sudo firewall-cmd --permanent --add-rich-rule='rule family=\"ipv4\" source address=\"[\u4f60\u7684\u56fa\u5b9aIP]\" port port=\"22\" protocol=\"tcp\" accept'\r\nsudo firewall-cmd --permanent --remove-service=ssh\r\nsudo firewall-cmd --reload<\/span>\r\n\r\n# \u786e\u8ba4\u5f53\u524d\u8bbe\u7f6e\r\n<span style=\"color: #d1edff;\">sudo firewall-cmd --list-all\r\n<\/span><\/code><\/pre>\n<p>\u3007 \u9002\u7528\u4e8eUbuntu\uff08\u4f7f\u7528 UFW\uff09<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u4ec5\u5141\u8bb8\u6765\u81ea\u201c\u53ef\u4fe1\u56fa\u5b9aIP\u201d\u7684SSH\u8fde\u63a5\r\n<span style=\"color: #d1edff;\">sudo ufw allow from [\u4f60\u7684\u56fa\u5b9aIP] to any port 22<\/span>\r\n<span style=\"color: #d1edff;\">sudo ufw deny 22<\/span>\r\n<span style=\"color: #d1edff;\">sudo ufw reload#<\/span><\/code><\/pre>\n<h3>\u2461 \u5f3a\u5316SSH\u8bbe\u7f6e<\/h3>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"><span style=\"color: #d1edff;\">sudo nano \/etc\/ssh\/sshd_config<\/span><\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u8fdb\u884c\u4ee5\u4e0b\u4fee\u6539\u6216\u6dfb\u52a0\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"># \u7981\u7528\u5bc6\u7801\u8ba4\u8bc1\uff0c\u53ea\u5141\u8bb8\u5bc6\u94a5\u8ba4\u8bc1\r\n<span style=\"color: #d1edff;\">PasswordAuthentication no<\/span>\r\n\r\n# \u9650\u5236\u7279\u5b9a\u7528\u6237\u4ec5\u4ece\u6307\u5b9a\u56fa\u5b9aIP\u767b\u5f55\r\n<span style=\"color: #d1edff;\">AllowUsers username@[\u4f60\u7684\u56fa\u5b9aIP]<\/span>\r\n\r\n# \u7981\u6b62root\u7528\u6237\u767b\u5f55\r\n<span style=\"color: #d1edff;\">PermitRootLogin no<\/span><\/code><\/pre>\n<p>\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u91cd\u542fSSH\u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"><span style=\"color: #d1edff;\">sudo systemctl restart sshd<\/span><\/code><\/pre>\n<h3>\u2462 \u5efa\u7acbSSH\u96a7\u9053<\/h3>\n<p>\u5728\u5b8c\u6210\u56fa\u5b9aIP\u9650\u5236\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7SSH\u96a7\u9053\u5b89\u5168\u8fde\u63a5\u6570\u636e\u5e93\u3002<\/p>\n<p>\u901a\u8fc7SSH\u96a7\u9053\uff0c\u6240\u6709\u901a\u4fe1\u5747\u88ab\u52a0\u5bc6\uff0cMySQL\u76843306\u7aef\u53e3\u65e0\u9700\u5bf9\u5916\u5f00\u653e\uff0c\u4ece\u800c\u4fdd\u969c\u6570\u636e\u5e93\u5b89\u5168\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #fff; background: #282c34; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; border-radius: 0px; font-size: 16px; -webkit-overflow-scrolling: touch;\"><span style=\"color: #d1edff;\">sh -L 3306:localhost:3306 [\u4f60\u7684\u7528\u6237\u540d]@[\u670d\u52a1\u5668IP\u6216\u57df\u540d\u7b49]<\/span><\/code><\/pre>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u5c06\u6570\u636e\u5e93\u76f4\u63a5\u66b4\u9732\u5728\u4e92\u8054\u7f51\u4e0a\uff0c\u5c31\u50cf\u628a\u201c\u6ca1\u9501\u7684\u91d1\u5e93\u653e\u5728\u5927\u8857\u4e0a\u201d\u3002<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u4e8b\u540e\u540e\u6094\uff0c\u8bf7\u5c3d\u5feb\u786e\u8ba4\u4ee5\u4e0b\u4e09\u70b9\u3002<\/p>\n<p style=\"text-align: left;\">\u3007 \u68c0\u67e53306\u7aef\u53e3\u662f\u5426\u5bf9\u5916\u5f00\u653e<br \/>\n\u3007 \u82e5\u5df2\u5bf9\u5916\u5f00\u653e\uff0c\u7acb\u5373\u4fee\u6b63\u8bbe\u7f6e<br \/>\n\u3007 \u517b\u6210\u5b9a\u671f\u8fdb\u884c\u5b89\u5168\u68c0\u67e5\u7684\u4e60\u60ef<\/p>\n<h3>\u76f8\u5173\u670d\u52a1<\/h3>\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 50%; background-color: #138995;\"><span style=\"color: #ffffff;\">\u7f51\u7ad9\u5236\u4f5c<\/span><\/td>\n<td style=\"width: 50%;\"><a href=\"https:\/\/beyond-shenzhen.cn\/zh\/service\/website\" target=\"_blank\" rel=\"noopener\">https:\/\/beyond-shenzhen.cn\/zh\/service\/website<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; background-color: #138995;\"><span style=\"color: #ffffff;\">\u4e91\u670d\u52a1\u5668\u642d\u5efa<\/span><\/td>\n<td style=\"width: 50%;\"><a href=\"https:\/\/beyond-shenzhen.cn\/zh\/service\/server\" target=\"_blank\" rel=\"noopener\">https:\/\/beyond-shenzhen.cn\/zh\/service\/server<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 50%; background-color: #138995;\"><span style=\"color: #ffffff;\">\u4e91\u4e1a\u52a1\u7cfb\u7edf<\/span><\/td>\n<td style=\"width: 50%;\"><a href=\"https:\/\/beyond-shenzhen.cn\/zh\/service\/development\" target=\"_blank\" rel=\"noopener\">https:\/\/beyond-shenzhen.cn\/zh\/service\/development<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><a class=\"border-circle-inline\" href=\"https:\/\/beyond-shenzhen.cn\/zh\/contact\" target=\"_blank\" rel=\"noopener\">\u7f51\u7ad9\u5236\u4f5c\u3001\u4e91\u670d\u52a1\u5668\u642d\u5efa \u2014 \u670d\u52a1\u54a8\u8be2<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u7f51\u7ad9\u6216\u670d\u52a1\u5668\u7ba1\u7406\u5458\uff0c\u4e00\u4e9b\u770b\u4f3c\u4e0d\u8d77\u773c\u7684\u8bbe\u7f6e\uff0c\u53ef\u80fd\u4f1a\u5e26\u6765\u4e25\u91cd\u7684\u5b89\u5168\u98ce\u9669\uff0c\u800c\u7ba1\u7406\u5458\u672c\u4eba\u5f80\u5f80\u5e76\u672a\u5bdf\u89c9\u3002 \u5f88\u591a\u4eba\u4f1a\u60f3 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":22316,"template":"","meta":{"_acf_changed":false,"_locale":"zh_CN","_original_post":"https:\/\/beyond-shenzhen.cn\/?post_type=blog&p=22269"},"tags":[],"blogcat":[12],"class_list":["post-22611","blog","type-blog","status-publish","has-post-thumbnail","hentry","blogcat-it-web","zh-CN"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/beyond-shenzhen.cn\/wp-json\/wp\/v2\/blog\/22611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/beyond-shenzhen.cn\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/beyond-shenzhen.cn\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/beyond-shenzhen.cn\/wp-json\/wp\/v2\/users\/3"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/beyond-shenzhen.cn\/wp-json\/wp\/v2\/media\/22316"}],"wp:attachment":[{"href":"https:\/\/beyond-shenzhen.cn\/wp-json\/wp\/v2\/media?parent=22611"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/beyond-shenzhen.cn\/wp-json\/wp\/v2\/tags?post=22611"},{"taxonomy":"blogcat","embeddable":true,"href":"https:\/\/beyond-shenzhen.cn\/wp-json\/wp\/v2\/blogcat?post=22611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}