%20Gnu%2FLinux%20%E4%B8%8A%E3%81%AE%20PostGreSQL%2012%20%E7%94%A8%E3%81%AE%20~%2F.pgpass%20%E3%81%AE%E5%85%B7%E4%BD%93%E7%9A%84%E3%81%AA%E4%BE%8B%E3%81%AF%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%81%8B%3F.png)
のためにコロナウイルス対策GPLv3+プロジェクト(gitコミット109d5fb90f6ae
...) 実行中の具体的な例が必要ですファイル~/.pgpass
Debian (Buster) Gnu/Linux x86-64 上。
デバッグ中なので、ルート権限なしでデバッグできる必要があります。
PostgreSQL のの上デビアン/Busterはバージョン12です。このREADME.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
問題は解決しましたgitコミット5733fed27967d13
generate-config.py
Pythonスクリプトで
追伸:https://github.com/bstarynk/helpcovidプロジェクトは2020年3月に開始されます進行中
答え1
私はUbuntuを使っていますが、このリンクからPostgreSQLガイドに従うだけで済みます。Ubuntu 16.04 をインストールします。
その後、プロジェクトでコンパイル エラーが発生しましたmake localhost0
が、postgresql 接続部分は.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=>