简体   繁体   中英

Appveyor. What are the default Postgres credentials?

Documentation for Windows says that I may use user postgres with password Password12! . I found also this discussion, where they say: "We will fix both pg_hba.conf and password in next ubuntu image update." But it still doesn't work for me. I've also tried user postgres without password: no effect, the same authentication error. Maybe I'm just blind or misunderstand something, here is my basic AppVeyor configuration:

version: 1.0.{build}
skip_tags: true
branches:
  only:
    - master
image: Ubuntu2004
services:
  - postgresql
environment:
  PGUSER: postgres
  PGPASSWORD: Password12!
build_script:
  - echo $PWD $USER $PGUSER $PGPASSWORD
  - sudo psql -U postgres -c 'create database my_test_db;'

and here is the error I get:

Starting 'services'
Starting PostgreSQL
Running "build_script" scripts
echo $PWD $USER $PGUSER $PGPASSWORD
/opt/appveyor/build-agent appveyor postgres Password12!
sudo psql -U postgres -c 'create database my_test_db;'
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
Command exited with code 2
Build failed

Could someone help me, please?

I've finally found out a solution to my problem. As Adrian Klaver suggested in the comment under my post, I've checked pg_hba.conf file and found out that in the image Postgres is configured to use peer authentication Actually I've used the solution from here and changed the authentication method to trust. This configuration perfectly suits my needs. Here is the final appveyor.yml config:

version: 1.0.{build}
skip_tags: true
branches:
  only:
    - master
image: Ubuntu2004
services:
  - postgresql
environment:
  PGUSER: postgres
init:
  - sudo sed -i -E -e 's/(local\s+all\s+postgres\s+)peer/\1trust/' /etc/postgresql/14/main/pg_hba.conf
build_script:
  - psql -U postgres -c 'create database my_test_db;'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM