LoginSignup
0

More than 5 years have passed since last update.

PostgreSQLのsource版で日本語を表示させる場合

Last updated at Posted at 2016-05-20

普段あまり日本語で出力させる機会がないので少しハマっていました。

configureオプション

ポイントは最後の--enable-nlsというオプション

$ ./configure --prefix=/home/ikki/local/pg952/pgsql --with-pgport=5432 --enable-debug --enable-thread-safety --enable-cassert --with-libxml --with-libxslt --enable-nls
$ make
$ make install

PostgreSQLのDBクラスタを作成

make install後、initdbでDBクラスタを作成する。

$ initdb -D ~/local/pg952/data --no-locale --encoding=UTF-8
$ initdb -D ~/local/pg952/data --no-locale --encoding=utf-8
The files belonging to this database system will be owned by user "ikki".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".
・・・

PostgreSQLの設定ファイルを編集

しかし、このままではサーバログは英語表記のままです。

$ pg_ctl -D ~/local/pg952/data start
server starting
LOG:  database system was shut down at 2016-05-20 13:58:36 JST
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

なので、以下のように設定ファイルを編集する必要があります。

$ vi ~/local/pg952/data/postgresql.conf
lc_messages=ja_JP.UTF-8

あと、LANG=Cだと文字化けするので適宜変更しておきます。

$ export LANG=ja_JP.UTF-8

PostgreSQLを起動して表示を確認

起動時に以下のように日本語の表示がされていればOK

$ pg_ctl -D ~/local/pg952/data start
サーバは起動中です。
LOG:  データベースシステムは 2016-05-20 14:02:28 JST にシャットダウンしました
LOG:  MultiXact member wraparound protections are now enabled
LOG:  データベースシステムの接続受付準備が整いました。
LOG:  自動バキュームランチャプロセス

おわり。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0