无法连接到MySQL映像:无法创建与数据库服务器的连接

如何解决无法连接到MySQL映像:无法创建与数据库服务器的连接

我正在尝试从Java应用程序连接到MysqL映像,但是由于某种原因,它给了我:[08001] Could not create connection to database server. Attempted to reconnect 3 times. Giving up. java.net.ConnectException: Connection refused: connect.

它似乎试图访问数据库,但是登录信息不正确,尽管不是正确的。我将不胜感激,也许我只是盲目的。

我的docker-compose.yaml:

  version: "3.3"

services:

   db-MysqL:
       image: MysqL:8.0.21
       ports:
          - 3306:3306
       container_name: eRestaurant_db
       networks:
          - eRestaurant-network
       environment:
          MysqL_DATABASE: happy_tummy
          MysqL_ROOT_PASSWORD: password123
       volumes:
          - my-db:/var/lib/MysqL

volumes:
   my-db:

networks:
   eRestaurant-network:

在容器启动时堆叠:

    Recreating eRestaurant_db ... done                                                                                                                      Attaching to eRestaurant_db
eRestaurant_db | 2020-08-14 03:39:19+00:00 [Note] [Entrypoint]: Entrypoint script for MysqL Server 8.0.21-1debian10 started.
eRestaurant_db | 2020-08-14 03:39:19+00:00 [Note] [Entrypoint]: Switching to dedicated user 'MysqL'
eRestaurant_db | 2020-08-14 03:39:19+00:00 [Note] [Entrypoint]: Entrypoint script for MysqL Server 8.0.21-1debian10 started.
eRestaurant_db | 2020-08-14 03:39:20+00:00 [Note] [Entrypoint]: Initializing database files
eRestaurant_db | 2020-08-14T03:39:20.036357Z 0 [System] [MY-013169] [Server] /usr/sbin/MysqLd (MysqLd 8.0.21) initializing of server in progress as process 42
eRestaurant_db | 2020-08-14T03:39:20.042898Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
eRestaurant_db | 2020-08-14T03:39:20.956247Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
eRestaurant_db | 2020-08-14T03:39:22.903509Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
eRestaurant_db | 2020-08-14 03:39:27+00:00 [Note] [Entrypoint]: Database files initialized
eRestaurant_db | 2020-08-14 03:39:27+00:00 [Note] [Entrypoint]: Starting temporary server
eRestaurant_db | 2020-08-14T03:39:27.698855Z 0 [System] [MY-010116] [Server] /usr/sbin/MysqLd (MysqLd 8.0.21) starting as process 89
eRestaurant_db | 2020-08-14T03:39:27.718821Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
eRestaurant_db | 2020-08-14T03:39:27.944323Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
eRestaurant_db | 2020-08-14T03:39:28.061636Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/MysqLd/MysqLx.sock
eRestaurant_db | 2020-08-14T03:39:28.185890Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
eRestaurant_db | 2020-08-14T03:39:28.186075Z 0 [System] [MY-013602] [Server] Channel MysqL_main configured to support TLS. Encrypted connections are Now supported for this channel.
eRestaurant_db | 2020-08-14T03:39:28.192291Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/MysqLd' in the path is accessible to all OS users. Consider choosing a different directory.
eRestaurant_db | 2020-08-14T03:39:28.213335Z 0 [System] [MY-010931] [Server] /usr/sbin/MysqLd: ready for connections. Version: '8.0.21'  socket: '/var/run/MysqLd/MysqLd.sock'  port: 0  MysqL Community Server - GPL.
eRestaurant_db | 2020-08-14 03:39:28+00:00 [Note] [Entrypoint]: Temporary server started.
eRestaurant_db | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
eRestaurant_db | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
eRestaurant_db | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
eRestaurant_db | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
eRestaurant_db | 2020-08-14 03:39:31+00:00 [Note] [Entrypoint]: Creating database happy_tummy
eRestaurant_db |
eRestaurant_db | 2020-08-14 03:39:31+00:00 [Note] [Entrypoint]: Stopping temporary server
eRestaurant_db | 2020-08-14T03:39:31.451056Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down MysqLd (Version: 8.0.21).
eRestaurant_db | 2020-08-14T03:39:34.401782Z 0 [System] [MY-010910] [Server] /usr/sbin/MysqLd: Shutdown complete (MysqLd 8.0.21)  MysqL Community Server - GPL.
eRestaurant_db | 2020-08-14 03:39:34+00:00 [Note] [Entrypoint]: Temporary server stopped
eRestaurant_db |
eRestaurant_db | 2020-08-14 03:39:34+00:00 [Note] [Entrypoint]: MysqL init process done. Ready for start up.
eRestaurant_db |
eRestaurant_db | 2020-08-14T03:39:34.689506Z 0 [System] [MY-010116] [Server] /usr/sbin/MysqLd (MysqLd 8.0.21) starting as process 1
eRestaurant_db | 2020-08-14T03:39:34.699358Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
eRestaurant_db | 2020-08-14T03:39:34.928207Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
eRestaurant_db | 2020-08-14T03:39:35.042858Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060,socket: /var/run/MysqLd/MysqLx.sock
eRestaurant_db | 2020-08-14T03:39:35.123421Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
eRestaurant_db | 2020-08-14T03:39:35.123614Z 0 [System] [MY-013602] [Server] Channel MysqL_main configured to support TLS. Encrypted connections are Now supported for this channel.
eRestaurant_db | 2020-08-14T03:39:35.130639Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/MysqLd' in the path is accessible to all OS users. Consider choosing a different directory.
eRestaurant_db | 2020-08-14T03:39:35.150321Z 0 [System] [MY-010931] [Server] /usr/sbin/MysqLd: ready for connections. Version: '8.0.21'  socket: '/var/run/MysqLd/MysqLd.sock'  port: 3306  MysqL Community Server - GPL.

application.properties文件

spring.datasource.url=jdbc:MysqL://10.0.75.1:3306/happy_tummy?allowPublicKeyRetrieval=true&useSSL=false&createDatabaseIfNotExist=true
spring.datasource.username=root
spring.datasource.password=password123
spring.datasource.driver-class-name=com.MysqL.jdbc.Driver
spring.jpa.database-platform = org.hibernate.dialect.MysqL8Dialect
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto = update

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?