应用程序。默认的 Postgres 凭据是什么?

Appveyor. What are the default Postgres credentials?

Windows says that I may use user postgres with password Password12!. I found also this 讨论的文档,他们说:“我们将在下一次 ubuntu 图像更新中修复 pg_hba.conf 和密码。”但它仍然对我不起作用。我也试过 user postgres without password: no effect, 同样的认证错误。 也许我只是盲目或误解了什么,这是我的基本 AppVeyor 配置:

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;'

这是我得到的错误:

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

有人可以帮我吗?

我终于找到了解决问题的方法。正如 Adrian Klaver 在我的 post 下的评论中所建议的那样,我检查了 pg_hba.conf 文件并发现在图像中 Postgres 配置为使用 peer authentication Actually I've used the solution from here 并将身份验证方法更改为信任。这个配置非常适合我的需求。这是最终的 appveyor.yml 配置:

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/trust/' /etc/postgresql/14/main/pg_hba.conf
build_script:
  - psql -U postgres -c 'create database my_test_db;'