Report errors "FATAL: role "XXX" does not exist" when POSTGRES_USER is customized. #1155
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 |
Beta Was this translation helpful? Give feedback.
-
I tried to run docker ps --filter 'name=postgres' --format '{{.ID}}' CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bdb2469f4a82 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 1000
sleep 5
docker exec -it $RUNNING_POSTGRES_CONTAINER psql -U $DB_USER -d $DB_NAME -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASSWORD';" However, it reports : |
Beta Was this translation helpful? Give feedback.
-
According to https://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist, maybe i must use the system user |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Yes, i have installed locally. But i did not start local postgres, i just use the |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
I'm a totally newbie, trying to using a shell script to run postgres image.
Here is my code:
The errors I've been able to see are:
What am I missing and how can I fix this so I can actually proceed with Postgres?
When i set DB_USER to the default value
postgres
, it is Ok. But i just don't know the reason.Beta Was this translation helpful? Give feedback.
All reactions