解决方案:不要使用localhost或者127.0.0.1,使用内网的ip,就解决了
- SPRING_DATASOURCE_URL=jdbc:mysql://172.17.0.4:3306/davinci0.3?useUnicode=true&characterEncoding=UTF
[Druid-ConnectionPool-Create-1066270324] com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://localhost:3306/davinci0.3?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false, errorCode 0, state 08S01
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:172)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(Co

解决在docker-compose中使用localhost连接MySQL8时出现的通信链接失败问题,改用内网IP(如172.17.0.4)代替localhost即可正常建立连接。
最低0.47元/天 解锁文章
3746

被折叠的 条评论
为什么被折叠?



