7

I'm trying to create a database in PostgreSQL 9.4

CREATE DATABASE "dbname" WITH ENCODING 'UTF8';

but getting

ERROR:  encoding "UTF8" does not match locale "en_US"
DETAIL:  The chosen LC_CTYPE setting requires encoding "LATIN1".

error. PostgreSQL is on a vagrant box and I'm connecting to this db server over SSH tunneling. Vagrant box's locale settings :

root@precise32:/vagrant# locale
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

My computer's locale settings:

erayalakese at Eray-MacBook-Air in ~/Desktop/VAGRANTBOXES
$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

I didn't change locale settings after installing PostgreSQL 9.4.

How can I solve this problem?

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Eray
  • 7,038
  • 16
  • 70
  • 120

1 Answers1

12

While I don't know why it's choosing that locale, you can work around it by specifying LC_CTYPE etc too.

CREATE DATABASE "dbname" WITH ENCODING 'UTF8' LC_CTYPE 'en_US.UTF-8' LC_COLLATE 'en_US.UTF-8';

or similar.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • Thank you for response. I used your suggest and it's working. I will wait for a while to see if there any answer to this problem. If there is no answer, i'll accept yours. – Eray Oct 09 '15 at 06:01