Debian (Buster) Gnu/Linux 上 PostGreSQL 12 的 ~/.pgpass 的具體範例?

Debian (Buster) Gnu/Linux 上 PostGreSQL 12 的 ~/.pgpass 的具體範例?

為了幫助科維德GPLv3+ 項目(git 提交109d5fb90f6ae……)我們需要一個具體且有效的運行範例文件~/.pgpass在 Debian (Buster) Gnu/Linux x86-64 上。

我們正在調試,因此我們需要能夠在沒有 root 的情況下執行此操作。

後GreSQL德班/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

問題已解決git 提交5733fed27967d13

使用我們的generate-config.pypython 腳本


附言。這https://github.com/bstarynk/helpcovid專案時間為2020年3月工作正在進行中

答案1

我使用 Ubuntu,只需從此連結中遵循 postgresql 指南即可https://itsfoss.com/install-postgresql-ubuntu/

然後,在該專案中,我嘗試遇到編譯錯誤,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=> 

相關內容