docker-library / postgres

Docker Official Image packaging for Postgres
http://www.postgresql.org
MIT License
2.14k stars 1.11k forks source link

Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "smartloy_user" #1218

Closed abkarim closed 3 months ago

abkarim commented 3 months ago

Unable to login from adminer (note: I'm just starting with postgres, i have not tried to login from anything else at this point) while username and password are correct (I have checked many times)

docker-compose.yml

version: '3.8'
services:
  postgres_db_smartloy:
    image: postgres
    container_name: smartloydb
    restart: always
    volumes:
      - ./data/db:/var/lib/postgres/data
    ports:
      - '5432:5432'
    environment:
      - POSTGRES_DB=smartloy
      - POSTGRES_USER=smartloy_user
      - POSTGRES_PASSWORD=smartloy_353##$$
    networks:
      - smartloy

  adminer:
    image: adminer
    container_name: adminer
    restart: always
    ports:
      - '8080:8080'
    networks:
      - smartloy

networks:
  smartloy:

Screenshot from 2024-03-23 19-32-35

Device:

Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:    12
Codename:   bookworm

Docker:

Client:
 Version:           20.10.24+dfsg1
 API version:       1.41
 Go version:        go1.19.8
 Git commit:        297e128
 Built:             Thu May 18 08:38:34 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.24+dfsg1
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       5d6db84
  Built:            Thu May 18 08:38:34 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.20~ds1
  GitCommit:        1.6.20~ds1-1+b1
 runc:
  Version:          1.1.5+ds1
  GitCommit:        1.1.5+ds1-1+deb12u1
 docker-init:
  Version:          0.19.0
  GitCommit:        
docker-compose version 1.29.2, build unknown
docker-py version: 5.0.3
CPython version: 3.11.2
OpenSSL version: OpenSSL 3.0.11 19 Sep 2023
abkarim commented 3 months ago

Starts working after changing password in docker-compose.yml file (not sure why but it's working now)

felipeit commented 3 months ago

idk why but for me nothing is working....

abkarim commented 3 months ago

@felipeit I'm also unable to detect the issue, but changing password to simple text like "user_pass" worked for me previously it was like "user_pass@#@$@$2".

Are you getting the same error "password authentication failed for user 'user'" ?

LaurentGoderre commented 3 months ago

The hash sign # creates a comment in yaml. You should put double quote character around your password if it contains special characters

felipeit commented 3 months ago

Yeah @abkarim image

this is something with SCRAM authentication.

docker-compose.yml image

felipeit commented 3 months ago

i have set POSTGRES_HOST_AUTH_METHOD like md5 but dont have effect... image