Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password does not match for user "postgres"

I am trying to raise a service in my docker-compose to use postgres, I can raise the container correctly, the problem is that it does not allow me to authenticate with the password that I am setting in the environment variables

this is my docker-compose service:

version: "3"
services:
  api:
    build:
      context: .
      dockerfile: docker/nodejs/Dockerfile
    ports:
      - "3000:3000"
    volumes:
      - .:/app
    links:
      - postgresql

  postgresql:
    image: postgres:11-alpine
    restart: always
    environment:
      POSTGRES_PASSWORD: 00000000
    volumes:
      - ~/docker/postgresql:/var/lib/postgresql/data
    ports:
      - "5432:5432"

what can be the problem here? i trying to get in with pgadmin. In the console show me the error:

password authentication failed for user "postgres"
Password does not match for user "postgres".
like image 678
kmilo93sd Avatar asked Feb 19 '19 11:02

kmilo93sd


Video Answer


2 Answers

The Postgres password is set on the first initialization if the db (when the var/lib/postgresql/data folder is empty). Since you probably ran docker-compose before with a different password, the new one will not take effect. To fix this, remove the volume in your host machine and have docker-compose automatically recreate it next time you run docker-compose up. Note that removing this volume will delete all data stored in PostgreSQL

like image 65
camba1 Avatar answered Oct 19 '22 18:10

camba1


Another way to fail with POSTGRES_PASSWORD is to set a password with forbidden characters. You won't get any warnings, but you won't be able to login with this password.

like image 41
Midriaz Avatar answered Oct 19 '22 18:10

Midriaz