Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The chosen LC_CTYPE setting requires encoding "LATIN1"

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?

like image 237
Eray Avatar asked Oct 09 '15 00:10

Eray


1 Answers

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.

like image 178
Craig Ringer Avatar answered Nov 10 '22 14:11

Craig Ringer