GeekBox

IT系エンジニアの雑記

【postgreSQL】psqlでSQLを実行すると「has no equivalent in encoding 」が出る

スポンサーリンク

psqlSQLを実行すると以下のようなエラーが出力される。

ERROR: character with byte sequence 0xe7 0xac 0xa6 in encoding "UTF8" has no equivalent in encoding "LATIN1"

■環境情報 VirtualBoxCentOS Linux release 7.2.1511 PostgreSQL 9.2.15

クライアントのエンコーディング設定の問題なので以下手順で修正する。

クライアントのエンコーディング設定を確認

db_name=> show client_encoding;

エラー内容に出てきた"LATIN1"が出力される。

client_encoding
-----------------
LATIN1

エンコーディングのセット

db_name=> SET client_encoding = 'UTF8';

確認してみる

db_name=> show client_encoding;

設定が反映されている事が確認できる

client_encoding
-----------------
UTF8