08 « 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.» 10

MacOSX(Mountain Lion)+ Postgres.app エンコード「EUC_JP」のDBが作成できない 

MountainLion には標準で postgresが入っているのですが、使うには設定や起動スクリプトやらで面倒そうなので「postgres.app」をインストール


ダウンロードしたら /Applications などに移動して起動するだけで使えます。
postgresapp.png


そのままだと標準で入っているpostgresコマンドが優先されるので、パスを追加しておいた方が便利です。

vi ~/.bash_profile
---(下記を追加)---------------------------
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
export PATH
------------------------------



早速DBを作ろうとするが、エンコーディングに「EUC_JP」を指定すると、エラーが発生してDB作成できない。

createdb -E EUC_JP -T template0 testdb
------------------------------
createdb: database creation failed: ERROR: encoding EUC_JP does not match locale ja_JP
DETAIL: The chosen LC_CTYPE setting requires encoding UTF8.
------------------------------


postgres8.4.x 頃までは、「-T」オプションでテンプレートを指定すればOKだったが、postgres.app(バージョン9.1.4)ではさらに「-l」オプションでロケールを「C」に指定する必要がある。

createdb -E EUC_JP -T template0 -l C testdb
psql -l
------------------------------
(略)
testdb | admin | EUC_JP | C | C |
------------------------------


無事にエンコーディング「EUC_JP」のDBが作成できました。(^^)/

スポンサーサイト



Posted on 2012/09/02 Sun. 17:34 [edit]

category: サーバ

thread: Mac  -  janre: コンピュータ

TB: 0    CM: 0

02