{"id":38153,"date":"2025-05-19T17:36:01","date_gmt":"2025-05-19T09:36:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/38153.html"},"modified":"2025-05-19T17:36:01","modified_gmt":"2025-05-19T09:36:01","slug":"%e6%88%91linux%e6%9c%8d%e5%8a%a1%e5%99%a8%ef%bc%8c%e7%94%a8docker%e5%ae%89%e8%a3%85%e4%ba%86mysql%ef%bc%8c5-7%e7%89%88%e6%9c%ac%ef%bc%8c-%e6%9c%ac%e5%9c%b0%e8%bf%9e%e6%8e%a5%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/38153.html","title":{"rendered":"\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519"},"content":{"rendered":"<p>\u5927\u5bb6\u597d&#xff0c;\u6211\u662f\u527d\u608d\u4e00\u5c0f\u5154&#xff0c;\u72ec\u7acb\u5f00\u53d1\u8005&#xff0c;\u526f\u4e1a\u641e\u94b1\u5c1d\u8bd5\u8005&#xff0c;\u70ed\u7231\u6280\u672f\u5206\u4eab&#xff0c;\u6b22\u8fce\u4e00\u8d77\u5b66\u4e60\u4ea4\u6d41\u3002<\/p>\n<p>\u6211\u4f1a\u6bcf\u5929\u5206\u4eab\u7f16\u7a0b\u6280\u672f\u3001\u72ec\u7acb\u5f00\u53d1\u3001\u884c\u4e1a\u54a8\u8be2\u3001\u601d\u8003\u611f\u609f\u3002<\/p>\n<p>\u4ee3\u8868\u4f5c&#xff1a;\u300aJavaScript\u767e\u70bc\u6210\u4ed9\u300b<\/p>\n<p>\u516c\u4f17\u53f7&#xff1a;java\u5c0f\u767d\u7ffb\u8eab<\/p>\n<p>\u5c0f\u7a0b\u5e8f&#xff1a;\u901f\u7528\u767e\u5b9d\u7bb1<\/p>\n<\/p>\n<p>\u8981\u89e3\u51b3 Docker MySQL 5.7 \u5728\u670d\u52a1\u5668\u4e0a\u88ab Spring Boot JAR \u5305\u8fde\u63a5\u5931\u8d25\u7684\u95ee\u9898&#xff0c;\u9700\u8981\u7ed3\u5408\u7f51\u7edc\u8fde\u901a\u6027\u3001\u914d\u7f6e\u4e00\u81f4\u6027\u548cMySQL \u6743\u9650\u7b49\u7ef4\u5ea6\u6392\u67e5\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u5206\u6790\u548c\u89e3\u51b3\u6b65\u9aa4&#xff1a;<\/p>\n<h4>\u4e00\u3001\u4f18\u5148\u68c0\u67e5\u9519\u8bef\u65e5\u5fd7<\/h4>\n<p>\u542f\u52a8 JAR \u5305\u65f6&#xff0c;\u52a1\u5fc5\u67e5\u770b\u5b8c\u6574\u7684\u62a5\u9519\u4fe1\u606f&#xff08;\u5982\u00a0java.sql.SQLException\u00a0\u7684\u5177\u4f53\u539f\u56e0&#xff09;&#xff0c;\u5e38\u89c1\u9519\u8bef\u7c7b\u578b\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\u2022\u00a0Connection refused&#xff08;\u8fde\u63a5\u88ab\u62d2\u7edd&#xff09;&#xff1a;\u53ef\u80fd\u662f\u7f51\u7edc\u4e0d\u901a\u6216\u7aef\u53e3\u672a\u5f00\u653e\u3002<\/li>\n<li>\u2022\u00a0Access denied for user&#xff08;\u6743\u9650\u4e0d\u8db3&#xff09;&#xff1a;\u7528\u6237\u540d\/\u5bc6\u7801\u9519\u8bef\u6216 MySQL \u7528\u6237\u672a\u6388\u6743\u5f53\u524d\u4e3b\u673a\u3002<\/li>\n<li>\u2022\u00a0Communications link failure&#xff08;\u8fde\u63a5\u8d85\u65f6&#xff09;&#xff1a;\u7f51\u7edc\u5ef6\u8fdf\u6216 MySQL \u914d\u7f6e\u9650\u5236\u3002<\/li>\n<li>\u2022\u00a0ClassNotFoundException: com.mysql.cj.jdbc.Driver&#xff08;\u9a71\u52a8\u7f3a\u5931&#xff09;&#xff1a;JAR \u5305\u672a\u6b63\u786e\u6253\u5305\u9a71\u52a8\u3002<\/li>\n<\/ul>\n<h4>\u4e8c\u3001\u6838\u5fc3\u6392\u67e5\u6b65\u9aa4<\/h4>\n<h5>1. \u786e\u8ba4 MySQL \u5bb9\u5668\u7684\u7f51\u7edc\u914d\u7f6e<\/h5>\n<p>Docker MySQL \u5bb9\u5668\u9ed8\u8ba4\u4f7f\u7528\u00a0bridge\u00a0\u7f51\u7edc\u6a21\u5f0f&#xff0c;\u5bbf\u4e3b\u673a\u8bbf\u95ee\u5bb9\u5668\u9700\u901a\u8fc7\u00a0\u5bbf\u4e3b\u673aIP:\u6620\u5c04\u7aef\u53e3&#xff08;\u800c\u975e\u5bb9\u5668\u5185\u90e8IP&#xff09;\u3002\u9700\u68c0\u67e5&#xff1a;<\/p>\n<ul>\n<li>\u2022\u00a0\u7aef\u53e3\u6620\u5c04\u662f\u5426\u6b63\u786e&#xff1a;\u901a\u8fc7\u00a0docker ps\u00a0\u67e5\u770b\u5bb9\u5668\u7aef\u53e3\u6620\u5c04&#xff08;\u5982\u00a00.0.0.0:3306-&gt;3306\/tcp&#xff09;&#xff0c;\u786e\u4fdd\u5bbf\u4e3b\u673a\u7684 3306 \u7aef\u53e3\u5df2\u6620\u5c04\u5230\u5bb9\u5668\u5185\u90e8\u3002 docker\u00a0ps\u00a0|\u00a0grep\u00a0mysql\u00a0\u00a0#\u00a0\u67e5\u770b\u5bb9\u5668\u7aef\u53e3\u6620\u5c04 <\/li>\n<li>\u2022\u00a0\u5bb9\u5668\u662f\u5426\u5141\u8bb8\u5916\u90e8\u8fde\u63a5&#xff1a;MySQL \u914d\u7f6e\u6587\u4ef6&#xff08;my.cnf\u00a0\u6216\u00a0my.ini&#xff09;\u4e2d\u7684\u00a0bind-address\u00a0\u9700\u8bbe\u7f6e\u4e3a\u00a00.0.0.0&#xff08;\u5141\u8bb8\u6240\u6709\u5730\u5740\u8fde\u63a5&#xff09;&#xff0c;\u5426\u5219\u4ec5\u5141\u8bb8\u00a0localhost\u00a0\u8bbf\u95ee\u3002 #\u00a0\u8fdb\u5165\u5bb9\u5668\u67e5\u770b\u914d\u7f6e<br \/>\ndocker\u00a0exec\u00a0-it\u00a0mysql-container-name\u00a0bash<br \/>\ncat\u00a0\/etc\/mysql\/my.cnf\u00a0|\u00a0grep\u00a0bind-address\u00a0\u00a0#\u00a0\u5e94\u663e\u793a\u00a0bind-address\u00a0&#061;\u00a00.0.0.0 <\/li>\n<\/ul>\n<h5>2. \u9a8c\u8bc1\u670d\u52a1\u5668\u4e0a JAR \u5305\u4e0e MySQL \u7684\u7f51\u7edc\u8fde\u901a\u6027<\/h5>\n<p>\u5728\u670d\u52a1\u5668\u4e0a\u76f4\u63a5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4&#xff0c;\u6d4b\u8bd5 JAR \u5305\u8fdb\u7a0b\u80fd\u5426\u8bbf\u95ee MySQL \u7aef\u53e3&#xff1a;<\/p>\n<p>#\u00a0\u66ff\u6362\u4e3a\u4f60\u7684\u00a0MySQL\u00a0\u5bbf\u4e3b\u673aIP\u548c\u6620\u5c04\u7aef\u53e3&#xff08;\u5982\u00a0127.0.0.1:3306&#xff09;<br \/>\ntelnet\u00a0127.0.0.1\u00a03306 <\/p>\n<ul>\n<li>\u2022 \u5982\u679c\u63d0\u793a\u00a0Connected to 127.0.0.1&#xff0c;\u8bf4\u660e\u7f51\u7edc\u8fde\u901a\u3002<\/li>\n<li>\u2022 \u5982\u679c\u63d0\u793a\u00a0Connection refused&#xff0c;\u53ef\u80fd\u662f&#xff1a;\n<ul>\n<li>\u2022 \u9632\u706b\u5899\u62e6\u622a&#xff08;\u5982\u00a0firewalld\u00a0\u6216\u4e91\u670d\u52a1\u5668\u5b89\u5168\u7ec4\u672a\u653e\u884c 3306 \u7aef\u53e3&#xff09;\u3002<\/li>\n<li>\u2022 MySQL \u5bb9\u5668\u672a\u6b63\u786e\u6620\u5c04\u7aef\u53e3&#xff08;\u68c0\u67e5\u00a0docker ps\u00a0\u7684\u7aef\u53e3\u6620\u5c04&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>3. \u68c0\u67e5 MySQL \u7528\u6237\u6743\u9650<\/h5>\n<p>MySQL \u7528\u6237\u53ef\u80fd\u4ec5\u6388\u6743\u4e86\u4ece\u00a0localhost\u00a0\u6216\u7279\u5b9a IP \u8bbf\u95ee&#xff0c;\u800c JAR \u5305\u8fd0\u884c\u5728\u670d\u52a1\u5668\u4e0a\u65f6&#xff0c;\u8fde\u63a5\u7684 IP \u4e0d\u5728\u6388\u6743\u5217\u8868\u4e2d\u3002\u9700\u767b\u5f55 MySQL \u68c0\u67e5\u7528\u6237\u6743\u9650&#xff1a;<\/p>\n<p>#\u00a0\u8fdb\u5165\u00a0MySQL\u00a0\u5bb9\u5668\u6267\u884c\u547d\u4ee4<br \/>\ndocker\u00a0exec\u00a0-it\u00a0mysql-container-name\u00a0mysql\u00a0-uroot\u00a0-p<\/p>\n<p>#\u00a0\u67e5\u770b\u7528\u6237\u6743\u9650&#xff08;\u66ff\u6362\u4e3a\u4f60\u7684\u7528\u6237\u540d&#xff0c;\u5982\u00a0spring_user&#xff09;<br \/>\nmysql&gt;\u00a0SELECT\u00a0Host,\u00a0User\u00a0FROM\u00a0mysql.user\u00a0WHERE\u00a0User\u00a0&#061;\u00a0&#039;spring_user&#039;; <\/p>\n<ul>\n<li>\u2022 \u5982\u679c\u00a0Host\u00a0\u662f\u00a0localhost&#xff0c;\u8868\u793a\u4ec5\u5141\u8bb8\u672c\u5730&#xff08;\u5bb9\u5668\u5185&#xff09;\u8bbf\u95ee\u3002\u9700\u6388\u6743\u5141\u8bb8\u4ece\u670d\u52a1\u5668 IP \u8bbf\u95ee&#xff1a; &#8212;\u00a0\u6388\u6743\u7528\u6237\u4ece\u4efb\u610f\u4e3b\u673a\u8bbf\u95ee&#xff08;%\u00a0\u8868\u793a\u6240\u6709\u00a0IP&#xff09;<br \/>\nGRANT\u00a0ALL\u00a0PRIVILEGES\u00a0ON\u00a0*.*\u00a0TO\u00a0&#039;spring_user&#039;&#064;&#039;%&#039;\u00a0IDENTIFIED\u00a0BY\u00a0&#039;\u4f60\u7684\u5bc6\u7801&#039;\u00a0WITH\u00a0GRANT\u00a0OPTION;<br \/>\nFLUSH\u00a0PRIVILEGES;\u00a0\u00a0&#8212;\u00a0\u5237\u65b0\u6743\u9650 <\/li>\n<\/ul>\n<h5>4. \u786e\u8ba4 JAR \u5305\u7684\u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e<\/h5>\n<p>\u672c\u5730\u5f00\u53d1\u65f6&#xff0c;\u8fde\u63a5\u914d\u7f6e\u53ef\u80fd\u4f7f\u7528\u00a0localhost:3306&#xff0c;\u4f46\u90e8\u7f72\u5230\u670d\u52a1\u5668\u540e&#xff0c;\u9700\u786e\u4fdd\u914d\u7f6e\u6307\u5411\u00a0\u5bbf\u4e3b\u673a\u7684 MySQL \u6620\u5c04\u7aef\u53e3&#xff08;\u800c\u975e\u5bb9\u5668\u5185\u90e8 IP&#xff09;\u3002\u68c0\u67e5\u00a0application.properties\u00a0\u6216\u00a0application.yml&#xff1a;<\/p>\n<p>spring:<br \/>\n\u00a0\u00a0datasource:<br \/>\n\u00a0\u00a0\u00a0\u00a0url:\u00a0jdbc:mysql:\/\/\u5bbf\u4e3b\u673aIP:\u6620\u5c04\u7aef\u53e3\/\u6570\u636e\u5e93\u540d?useUnicode&#061;true&amp;characterEncoding&#061;utf-8&amp;useSSL&#061;false&amp;serverTimezone&#061;Asia\/Shanghai<br \/>\n\u00a0\u00a0\u00a0\u00a0username:\u00a0spring_user<br \/>\n\u00a0\u00a0\u00a0\u00a0password:\u00a0\u4f60\u7684\u5bc6\u7801<br \/>\n\u00a0\u00a0\u00a0\u00a0driver-class-name:\u00a0com.mysql.cj.jdbc.Driver\u00a0\u00a0#\u00a0MySQL\u00a05.7\u00a0\u5efa\u8bae\u4f7f\u7528\u00a08.x\u00a0\u9a71\u52a8&#xff08;\u517c\u5bb9&#xff09; <\/p>\n<ul>\n<li>\u2022\u00a0\u6ce8\u610f&#xff1a;\u5982\u679c JAR \u5305\u8fd0\u884c\u5728\u670d\u52a1\u5668\u4e0a&#xff0c;\u4e14 MySQL \u5bb9\u5668\u4e5f\u5728\u540c\u4e00\u670d\u52a1\u5668&#xff0c;\u5bbf\u4e3b\u673aIP\u00a0\u5e94\u586b\u5199\u00a0127.0.0.1\u00a0\u6216\u670d\u52a1\u5668\u516c\u7f51 IP&#xff08;\u9700\u786e\u4fdd\u9632\u706b\u5899\u653e\u884c&#xff09;\u3002<\/li>\n<\/ul>\n<h5>5. \u68c0\u67e5 JDBC \u9a71\u52a8\u7248\u672c\u517c\u5bb9\u6027<\/h5>\n<p>MySQL 5.7 \u63a8\u8350\u4f7f\u7528\u00a0mysql-connector-java 5.1.x\u00a0\u6216\u00a08.x\u00a0\u9a71\u52a8&#xff08;8.x \u9700\u6dfb\u52a0\u00a0serverTimezone\u00a0\u53c2\u6570&#xff09;\u3002\u5982\u679c JAR \u5305\u672a\u6b63\u786e\u6253\u5305\u9a71\u52a8&#xff0c;\u6216\u7248\u672c\u4e0d\u517c\u5bb9&#xff0c;\u4f1a\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u3002\u68c0\u67e5\u00a0pom.xml&#xff08;Maven&#xff09;\u6216\u00a0build.gradle&#xff08;Gradle&#xff09;&#xff1a;<\/p>\n<p>&lt;!&#8211;\u00a0Maven\u00a0\u4f9d\u8d56&#xff08;MySQL\u00a05.7\u00a0\u517c\u5bb9\u00a08.x\u00a0\u9a71\u52a8&#xff09;\u00a0&#8211;&gt;<br \/>\n&lt;dependency&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0&lt;groupId&gt;mysql&lt;\/groupId&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0&lt;artifactId&gt;mysql-connector-java&lt;\/artifactId&gt;<br \/>\n\u00a0\u00a0\u00a0\u00a0&lt;version&gt;8.0.28&lt;\/version&gt;\u00a0\u00a0&lt;!&#8211;\u00a0\u63a8\u8350\u00a08.x\u00a0\u7248\u672c\u00a0&#8211;&gt;<br \/>\n&lt;\/dependency&gt; <\/p>\n<ul>\n<li>\u2022 \u6253\u5305\u65f6\u786e\u4fdd\u9a71\u52a8\u88ab\u6b63\u786e\u5305\u542b&#xff08;Maven \u9700\u786e\u8ba4\u00a0scope\u00a0\u4e3a\u00a0compile&#xff0c;\u800c\u975e\u00a0provided&#xff09;\u3002<\/li>\n<\/ul>\n<h5>6. \u68c0\u67e5\u5bb9\u5668\u4e0e\u5bbf\u4e3b\u673a\u7684\u7f51\u7edc\u9694\u79bb<\/h5>\n<p>\u5982\u679c MySQL \u5bb9\u5668\u4f7f\u7528\u00a0bridge\u00a0\u7f51\u7edc&#xff08;\u9ed8\u8ba4&#xff09;&#xff0c;\u5bbf\u4e3b\u673a\u8bbf\u95ee\u5bb9\u5668\u9700\u901a\u8fc7\u00a0\u5bbf\u4e3b\u673aIP:\u6620\u5c04\u7aef\u53e3\u3002\u82e5\u5bb9\u5668\u4f7f\u7528\u00a0host\u00a0\u7f51\u7edc\u6a21\u5f0f&#xff08;&#8211;network host&#xff09;&#xff0c;\u5219\u5bb9\u5668\u76f4\u63a5\u4f7f\u7528\u5bbf\u4e3b\u673a\u7f51\u7edc&#xff0c;\u6b64\u65f6 MySQL \u7aef\u53e3\u5373\u4e3a\u5bbf\u4e3b\u673a\u7aef\u53e3\u3002<\/p>\n<h4>\u4e09\u3001\u5e38\u89c1\u95ee\u9898\u603b\u7ed3<\/h4>\n<table>\n<tr>\n<td>\u95ee\u9898\u7c7b\u578b<\/td>\n<td>\u73b0\u8c61\u63cf\u8ff0<\/td>\n<td>\u89e3\u51b3\u65b9\u6cd5<\/td>\n<\/tr>\n<tbody>\n<tr>\n<td>\u7f51\u7edc\u4e0d\u901a<\/td>\n<td>telnet 127.0.0.1 3306\u00a0\u5931\u8d25<\/td>\n<td>\u68c0\u67e5\u9632\u706b\u5899\/\u5b89\u5168\u7ec4&#xff0c;\u786e\u8ba4\u7aef\u53e3\u6620\u5c04<\/td>\n<\/tr>\n<tr>\n<td>MySQL \u7528\u6237\u6743\u9650\u4e0d\u8db3<\/td>\n<td>\u62a5\u9519\u00a0Access denied<\/td>\n<td>\u6388\u6743\u7528\u6237\u00a0%\u00a0\u4e3b\u673a\u8bbf\u95ee\u6743\u9650<\/td>\n<\/tr>\n<tr>\n<td>\u8fde\u63a5\u914d\u7f6e\u9519\u8bef<\/td>\n<td>\u672c\u5730\u6b63\u5e38&#xff0c;\u670d\u52a1\u5668\u5931\u8d25<\/td>\n<td>\u68c0\u67e5\u00a0url\u00a0\u4e2d\u7684\u5bbf\u4e3b\u673a IP \u548c\u7aef\u53e3<\/td>\n<\/tr>\n<tr>\n<td>JDBC \u9a71\u52a8\u7f3a\u5931\u6216\u7248\u672c\u9519\u8bef<\/td>\n<td>\u62a5\u9519\u00a0ClassNotFoundException<\/td>\n<td>\u786e\u8ba4\u9a71\u52a8\u4f9d\u8d56\u5e76\u6b63\u786e\u6253\u5305<\/td>\n<\/tr>\n<tr>\n<td>MySQL\u00a0bind-address\u00a0\u9650\u5236<\/td>\n<td>\u5bb9\u5668\u5185\u53ef\u8fde&#xff0c;\u5bbf\u4e3b\u673a\u4e0d\u53ef\u8fde<\/td>\n<td>\u4fee\u6539\u00a0my.cnf\u00a0\u4e3a\u00a0bind-address&#061;0.0.0.0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u56db\u3001\u9a8c\u8bc1\u6b65\u9aa4<\/h4>\n<li>1. \u5728\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u00a0telnet 127.0.0.1 3306\u00a0\u786e\u8ba4\u7f51\u7edc\u8fde\u901a\u3002<\/li>\n<li>2. \u767b\u5f55 MySQL \u6267\u884c\u00a0SELECT Host, User FROM mysql.user\u00a0\u786e\u8ba4\u6743\u9650\u3002<\/li>\n<li>3. \u68c0\u67e5 JAR \u5305\u7684\u00a0application.yml\u00a0\u914d\u7f6e\u662f\u5426\u6307\u5411\u6b63\u786e\u7684\u5bbf\u4e3b\u673a IP \u548c\u7aef\u53e3\u3002<\/li>\n<li>4. \u91cd\u65b0\u6253\u5305 JAR \u5305&#xff08;\u786e\u4fdd\u9a71\u52a8\u5305\u542b&#xff09;&#xff0c;\u5e76\u91cd\u542f\u6d4b\u8bd5\u3002<\/li>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4&#xff0c;\u53ef\u4ee5\u5b9a\u4f4d\u5e76\u89e3\u51b3 90% \u4ee5\u4e0a\u7684 Docker MySQL \u8fde\u63a5\u95ee\u9898\u3002\u5982\u679c\u4ecd\u6709\u62a5\u9519&#xff0c;\u5efa\u8bae\u63d0\u4f9b\u5177\u4f53\u7684\u9519\u8bef\u65e5\u5fd7&#xff08;\u5982\u00a0java.sql.SQLException\u00a0\u7684\u8be6\u7ec6\u4fe1\u606f&#xff09;&#xff0c;\u4ee5\u4fbf\u8fdb\u4e00\u6b65\u6392\u67e5\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb763\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf8\u6b21\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5b9a\u4f4d\u5e76\u89e3\u51b3 90% \u4ee5\u4e0a\u7684 Docker MySQL \u8fde\u63a5\u95ee\u9898\u3002\u6216\u7279\u5b9a IP \u8bbf\u95ee\uff0c\u800c JAR \u5305\u8fd0\u884c\u5728\u670d\u52a1\u5668\u4e0a\u65f6\uff0c\u8fde\u63a5\u7684 IP \u4e0d\u5728\u6388\u6743\u5217\u8868\u4e2d\u3002\u8981\u89e3\u51b3 Docker MySQL 5.7 \u5728\u670d\u52a1\u5668\u4e0a\u88ab Spring Boot JAR \u5305\u8fde\u63a5\u5931\u8d25\u7684\u95ee\u9898\uff0c\u9700\u8981\u7ed3\u5408\u3002\u5927\u5bb6\u597d\uff0c\u6211\u662f\u527d\u608d\u4e00\u5c0f\u5154\uff0c\u72ec\u7acb\u5f00\u53d1\u8005\uff0c\u526f\u4e1a\u641e\u94b1\u5c1d\u8bd5\u8005\uff0c\u70ed\u7231\u6280\u672f\u5206\u4eab\uff0c\u6b22\u8fce\u4e00\u8d77\u5b66\u4e60\u4ea4\u6d41\u3002\u5982\u679c JAR \u5305\u672a\u6b63\u786e\u6253\u5305\u9a71\u52a8\uff0c\u6216\u7248\u672c\u4e0d\u517c\u5bb9\uff0c\u4f1a\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u3002\uff09\uff0c\u5219\u5bb9\u5668\u76f4\u63a5\u4f7f\u7528\u5bbf\u4e3b\u673a\u7f51\u7edc\uff0c\u6b64\u65f6 MySQL \u7aef\u53e3\u5373\u4e3a\u5bbf\u4e3b\u673a\u7aef\u53e3\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,58,43],"topic":[],"class_list":["post-38153","post","type-post","status-publish","format-standard","hentry","category-server","tag-docker","tag-linux","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/38153.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb763\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf8\u6b21\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5b9a\u4f4d\u5e76\u89e3\u51b3 90% \u4ee5\u4e0a\u7684 Docker MySQL \u8fde\u63a5\u95ee\u9898\u3002\u6216\u7279\u5b9a IP \u8bbf\u95ee\uff0c\u800c JAR \u5305\u8fd0\u884c\u5728\u670d\u52a1\u5668\u4e0a\u65f6\uff0c\u8fde\u63a5\u7684 IP \u4e0d\u5728\u6388\u6743\u5217\u8868\u4e2d\u3002\u8981\u89e3\u51b3 Docker MySQL 5.7 \u5728\u670d\u52a1\u5668\u4e0a\u88ab Spring Boot JAR \u5305\u8fde\u63a5\u5931\u8d25\u7684\u95ee\u9898\uff0c\u9700\u8981\u7ed3\u5408\u3002\u5927\u5bb6\u597d\uff0c\u6211\u662f\u527d\u608d\u4e00\u5c0f\u5154\uff0c\u72ec\u7acb\u5f00\u53d1\u8005\uff0c\u526f\u4e1a\u641e\u94b1\u5c1d\u8bd5\u8005\uff0c\u70ed\u7231\u6280\u672f\u5206\u4eab\uff0c\u6b22\u8fce\u4e00\u8d77\u5b66\u4e60\u4ea4\u6d41\u3002\u5982\u679c JAR \u5305\u672a\u6b63\u786e\u6253\u5305\u9a71\u52a8\uff0c\u6216\u7248\u672c\u4e0d\u517c\u5bb9\uff0c\u4f1a\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u3002\uff09\uff0c\u5219\u5bb9\u5668\u76f4\u63a5\u4f7f\u7528\u5bbf\u4e3b\u673a\u7f51\u7edc\uff0c\u6b64\u65f6 MySQL \u7aef\u53e3\u5373\u4e3a\u5bbf\u4e3b\u673a\u7aef\u53e3\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/38153.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-19T09:36:01+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38153.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/38153.html\",\"name\":\"\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-19T09:36:01+00:00\",\"dateModified\":\"2025-05-19T09:36:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/38153.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/38153.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38153.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/38153.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb763\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf8\u6b21\u3002\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5b9a\u4f4d\u5e76\u89e3\u51b3 90% \u4ee5\u4e0a\u7684 Docker MySQL \u8fde\u63a5\u95ee\u9898\u3002\u6216\u7279\u5b9a IP \u8bbf\u95ee\uff0c\u800c JAR \u5305\u8fd0\u884c\u5728\u670d\u52a1\u5668\u4e0a\u65f6\uff0c\u8fde\u63a5\u7684 IP \u4e0d\u5728\u6388\u6743\u5217\u8868\u4e2d\u3002\u8981\u89e3\u51b3 Docker MySQL 5.7 \u5728\u670d\u52a1\u5668\u4e0a\u88ab Spring Boot JAR \u5305\u8fde\u63a5\u5931\u8d25\u7684\u95ee\u9898\uff0c\u9700\u8981\u7ed3\u5408\u3002\u5927\u5bb6\u597d\uff0c\u6211\u662f\u527d\u608d\u4e00\u5c0f\u5154\uff0c\u72ec\u7acb\u5f00\u53d1\u8005\uff0c\u526f\u4e1a\u641e\u94b1\u5c1d\u8bd5\u8005\uff0c\u70ed\u7231\u6280\u672f\u5206\u4eab\uff0c\u6b22\u8fce\u4e00\u8d77\u5b66\u4e60\u4ea4\u6d41\u3002\u5982\u679c JAR \u5305\u672a\u6b63\u786e\u6253\u5305\u9a71\u52a8\uff0c\u6216\u7248\u672c\u4e0d\u517c\u5bb9\uff0c\u4f1a\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u3002\uff09\uff0c\u5219\u5bb9\u5668\u76f4\u63a5\u4f7f\u7528\u5bbf\u4e3b\u673a\u7f51\u7edc\uff0c\u6b64\u65f6 MySQL \u7aef\u53e3\u5373\u4e3a\u5bbf\u4e3b\u673a\u7aef\u53e3\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/38153.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-19T09:36:01+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/38153.html","url":"https:\/\/www.wsisp.com\/helps\/38153.html","name":"\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-19T09:36:01+00:00","dateModified":"2025-05-19T09:36:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/38153.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/38153.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/38153.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6211linux\u670d\u52a1\u5668\uff0c\u7528docker\u5b89\u88c5\u4e86mysql\uff0c5.7\u7248\u672c\uff0c \u672c\u5730\u8fde\u63a5\u670d\u52a1\u5668\u7684mysql\u662f\u6b63\u5e38\u7684\uff0c\u8dd1springboot\u9879\u76ee\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8fde\u63a5\uff0c\u4f46\u662f\u6253\u6210jar\u540e\u653e\u5230\u670d\u52a1\u5668\u53bb\u542f\u52a8\uff0c\u5c31\u8fde\u63a5mysql\u62a5\u9519"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=38153"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38153\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=38153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=38153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=38153"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=38153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}