我在 docker 上
docker run --name database -e POSTGRES_PASSWORD=password -d -p 5436:5436 postgres
創建了資料庫: 在里面創建了一些資料庫:
createdb database
還創建了超級用戶。現在我正在嘗試從本地主機連接:
psql -h localhost -p 5436 -U postgres
之后我收到以下錯誤:
psql: The server closed the connection unexpectedly
This probably means that the server has terminated abnormally
before or while processing your inquiry.
埠已連接:

uj5u.com熱心網友回復:
在您的情況下,您正在嘗試公開5436和映射主機埠5436,但這可能需要使用-p 5436:5432,因為 Postgres 使用埠 5432 作為默認埠。
docker run --name database -e POSTGRES_PASSWORD=password -d -p 5436:5432 postgres
容器網路有一些描述
-p 8080:80:將容器中的 TCP 80 埠映射到 Docker 主機上的 8080 埠。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/447399.html
標籤:PostgreSQL 码头工人
上一篇:如何在postgresql中拆分一個字串,如果為空則回傳另一個字串
下一篇:如何使用JPQL獲得今天的物品
