6月22日からFjordBootCampでプログラミングを勉強してます!

LinuxにPostgreSQLをインストール/testユーザーの作成

Linux(Debian)にpostgreSQLをインストールする

$ sudo apt install postgresql
$ psql --version
psql (PostgreSQL) 11.7 (Debian 11.7-0+deb10u1)

postgreSQLの中にtestユーザーを追加する

参考 ロール(ユーザー)の作成

postgres=# CREATE ROLE test with LOGIN PASSWORD 'testtest';
CREATE ROLE
postgres=# \du;
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 test      |                                                            | {}

postgres=# exit

testユーザを使ってpostgreSQLへ接続する

$ psql -U test -h localhost
Password for user test: 
psql (11.7 (Debian 11.7-0+deb10u1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)

参考 PostgreSQLのPeer認証と他の認証方法への変更