- Notifications
You must be signed in to change notification settings - Fork1.2k
Report errors "FATAL: role "XXX" does not exist" when POSTGRES_USER is customized.#1155
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I'm a totally newbie, trying to using a shell script to run postgres image. DB_USER="${POSTGRES_USER:=admin}"DB_PASSWORD="${POSTGRES_PASSWORD:=admin}"DB_NAME="${POSTGRES_DB:=scaffold}"DB_PORT="${POSTGRES_PORT:=5432}"DB_HOST="${POSTGRES_HOST:=localhost}"docker run \ --name"postgres_$(date'+%s')" \ -e POSTGRES_USER=${DB_USER} \ -e POSTGRES_PASSWORD=${DB_PASSWORD} \ -e POSTGRES_DB=${DB_NAME} \ -p"${DB_PORT}":5432 \ -d \ postgres -N 1000until PGPASSWORD="${DB_PASSWORD}" psql -h"${DB_HOST}" -U"${DB_USER}" -p"${DB_PORT}" -d"postgres" -c'\q';do>&2echo"Postgres is still unavailable - sleeping" sleep 1done The errors I've been able to see are: psql: error: connection to server at"localhost" (127.0.0.1), port 5432 failed: FATAL: role"admin" does not exist What am I missing and how can I fix this so I can actually proceed with Postgres? |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 6 comments 1 reply
-
I just tried this and I was able to connect. Maybe there is an issue with your docker networking. What do you get if you run |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I tried to run docker ps --filter'name=postgres' --format'{{.ID}}' CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESbdb2469f4a82 postgres"docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:5432->5432/tcp postgres_1698292090 I thought after running docker run \ --name"${RUNNING_POSTGRES_CONTAINER}" \ -e POSTGRES_USER=${DB_USER} \ -e POSTGRES_PASSWORD=${DB_PASSWORD} \ -e POSTGRES_DB=${DB_NAME} \ -p"${DB_PORT}":5432 \ -d \ postgres -N 1000sleep 5dockerexec -it$RUNNING_POSTGRES_CONTAINER psql -U$DB_USER -d$DB_NAME -c"CREATE USER$DB_USER WITH PASSWORD '$DB_PASSWORD';" However, it reports : |
BetaWas this translation helpful?Give feedback.
All reactions
-
According tohttps://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist, maybe i must use the system user |
BetaWas this translation helpful?Give feedback.
All reactions
-
The user is successfully created. Do you have postgres installed locally as well? I am wondering if your script isn't connecting to your container postgres but another one. |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
-
you are right, thank you!, i got the similar problem, and i used"ps aux | grep postgres"to check, and i found another pgsql existed, when i removed it, theproblem was solved. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes, i have installed locally. But i did not start local postgres, i just use the |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
File "/home/gridsentry/imgaudit/GAudit/myenv/lib/python3.8/site-packages/psycopg2/init.py", line 122, in connect Projectexport ENV_HOME=$PWD Databaseexport ENV_DB_USER=gaudit Super Adminexport ENV_ADMIN_USER=gsadmin Serverexport ENV_SERVER_TYPE=dev How to fix this issue? |
BetaWas this translation helpful?Give feedback.
All reactions
👎 1
This discussion was converted from issue #1138 on November 30, 2023 23:31.