PostgreSQL#

デフォルトのロケールの変更方法#

ロケールを調べると以下であった、

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | LATIN1   | en_US       | en_US       |
 redmine   | redmine  | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 |
 template0 | postgres | LATIN1   | en_US       | en_US       | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | LATIN1   | en_US       | en_US       | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres

これでは使いづらいので、以下としたい。

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 |
 redmine   | redmine  | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 |
 template0 | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres

方法#

https://makandracards.com/makandra/18643-how-to-change-the-locale-of-a-postgresql-cluster

リモートアクセスを許可する方法#

以下の2つのファイルを変更する。

  • /etc/postgresql/[version]/main/postgresql.conf

  • /etc/postgresql/[version]/main/pg_hba.conf

postgresql.conf#

listen_addressesにlistenするアドレスを追加する。 以下は192.168.30.0/24の内部ネットワークでDBのIPアドレスが192.168.30.254/24の例。

listen_addresses = 'localhost,192.168.30.254'

'*' とすれば全開(0.0.0.0/0)にできる。

pg_hba.conf#

以下は192.168.30.0/24の内部ネットワークからの接続を許す例。

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             192.168.30.0/24         md5 # 追加行