Debian(Buster) Gnu/Linux의 PostGreSQL 12에 대한 ~/.pgpass의 구체적인 예는 무엇입니까?

Debian(Buster) Gnu/Linux의 PostGreSQL 12에 대한 ~/.pgpass의 구체적인 예는 무엇입니까?

에 대한도움말코비드GPLv3+ 프로젝트(자식 커밋109d5fb90f6ae...) 우리는 달리기에 대한 구체적이고 실제적인 예가 필요합니다파일~/.pgpass데비안(버스터) Gnu/Linux x86-64.

우리는 디버깅 중이므로 루트 없이 디버깅할 수 있어야 합니다.

포스트그레SQL~에데비안/Buster는 버전 12입니다. 나는 이 지침을 따랐습니다.읽어보기.md

나는 평생 동안 PostGreSQL 데이터베이스를 배포한 적이 없습니다.

아래 예는 작동하지 않습니다. 이유를 모르겠습니다. (프랑스어 댓글이 있어서 죄송합니다.)

# fichier ~/.pgpass pour Basile en mars 2020
# voir  https://www.postgresql.org/docs/current/libpq-pgpass.html 
localhost:*:helpcovid_db:helpcovid_usr:test_helpcovid

해당 파일은 나만 읽을 수 있습니다.

% ls -l .pgpass 
-rw------- 1 basilest basilegr 164 Mar 22 12:38 .pgpass

문제가 해결됨자식 커밋5733fed27967d13

generate-config.pyPython 스크립트를 사용하면


추신. 그만큼https://github.com/bstarynk/helpcovid프로젝트는 2020년 3월에 있어요진행중인 작업

답변1

나는 Ubuntu를 사용하고 있으며 이 링크에서 postgresql 가이드를 따를 수 있습니다.https://itsfoss.com/install-postgresql-ubuntu/

그런 다음 프로젝트에서 컴파일 오류가 발생했지만 make localhost0postgresql 연결 부분은 .pgpass다음과 같은 방식으로 작동했습니다.

developer@1604:~/proj/github/helpcovid$ sudo su - postgres
postgres@1604:~$ psql -c "alter user postgres with password 'StrongPassword'"
ALTER ROLE
postgres@1604:~$ createuser dbuser1
postgres@1604:~$ createdb testdb -O dbuser1
postgres@1604:~$ psql -l  | grep testdb
 testdb    | dbuser1  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
postgres@1604:~$ psql
psql (11.7 (Ubuntu 11.7-2.pgdg18.04+1), server 9.5.14)
Type "help" for help.

postgres=# alter user dbuser1 with password 'StrongPassword';
ALTER ROLE
postgres=# create table test_table ( id int,first_name text, last_name text );
CREATE TABLE
postgres=# insert into test_table (id,first_name,last_name) values (1,'John','Doe');
INSERT 0 1
postgres=# select * from test_table;
 id | first_name | last_name 
----+------------+-----------
  1 | John       | Doe
(1 row)

postgres=# 

그러면 내 연결 문자열은 내 홈 디렉터리에 있습니다.

$ cat .pgpass 
localhost:5432:testdb:dbuser1:StrongPassword

그리고 프롬프트에서 연결할 수 있습니다.

developer@1604:~$ psql -d testdb -h localhost -U dbuser1
psql (11.7 (Ubuntu 11.7-2.pgdg18.04+1), server 9.5.14)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

testdb=> 

관련 정보