致命:数据库< name>不存在

发布于 2025-02-02 17:32:22 字数 1886 浏览 0 评论 0原文

我正在尝试使用PostgreSQL数据库创建自己的Spring Boot应用程序。我已经开始使用docker使用docker-compose其值如下:

version: "3"
services:
    products-postgresql:
      image: postgres:9.6
      restart: always
      ports:
        - 5450:5432
      environment:
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: superadmin
        POSTGRES_DB: products
      volumes:
        - D:\microservicios\workspace\SpringSecurity\volumes:/var/lib/postgresql/data:rw

带有docker-compose -d 命令,我设法轻松地将其提起, ”在此处输入图像描述

试图与dbeaver连接到数据库时,我会出现问题。我将其配置为新的PostgreSQL连接,传递了类似Docker-Compose的连接数据(Database = products,host> host = = = = = = = = = = = = = = = = = = localhost,用户 = postgres,password = superadmin ....),但它返回致命错误:数据库“产品”不存在

我已经看过类似的帖子,例如 PSQL:致命:数据库“”不存在,但它们对我不起作用。 我已经证实我没有使用同一端口的任何其他应用程序。

您能告诉我我可能做错了什么,或者我还剩下什么要配置的东西?谢谢

update :图像显示容器抬起我的数据库

“来自Docker”

I am trying to create my own Spring Boot application with a POSTGRESQL database. I have started using docker to mount the database, with a docker-compose whose values ​​are as follows:

version: "3"
services:
    products-postgresql:
      image: postgres:9.6
      restart: always
      ports:
        - 5450:5432
      environment:
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: superadmin
        POSTGRES_DB: products
      volumes:
        - D:\microservicios\workspace\SpringSecurity\volumes:/var/lib/postgresql/data:rw

With the docker-compose up -d command, I managed to get it up easily, enter image description here
enter image description here

The problem occurs to me when trying to connect with DBeaver to the database. I have configured it as a new POSTGRESQL connection, passing the connection data similar to those of docker-compose, (database = products, host = localhost, user = postgres, password = superadmin....) but it returns FATAL error: database "products" does not exist.

Imagen de conexion con DBeaver

I've seen similar posts, like this psql: FATAL: database "" does not exist , but they don't work for me.
I have verified that I don't have any other application using the same port.

Could you tell me what I may be doing wrong, or what I have left to configure? Thanks

UPDATE: Image showing that the container lifts my database

From Docker

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅一夜美梦 2025-02-09 17:32:22

尽管我仍然不明白为什么,但我必须将容器的端口更改为5432(Postgresql使用的端口),最终对我有用。

version: "3"
services:
    products-postgresql:
      image: postgres:9.6
      restart: always
      ports:
        - 5432:5432
      environment:
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: superadmin
        POSTGRES_DB: products
      volumes:
        - D:\microservicios\workspace\SpringSecurity\volumes:/var/lib/postgresql/data:rw

Although I still don't understand why, I had to change the port of my container to 5432 (the one used by POSTGRESQL), and it finally worked for me.

version: "3"
services:
    products-postgresql:
      image: postgres:9.6
      restart: always
      ports:
        - 5432:5432
      environment:
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: superadmin
        POSTGRES_DB: products
      volumes:
        - D:\microservicios\workspace\SpringSecurity\volumes:/var/lib/postgresql/data:rw
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文