LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   PostgreSQL Locale Problem Slackware 64 Stable (http://www.linuxquestions.org/questions/slackware-14/postgresql-locale-problem-slackware-64-stable-4175471003/)

tronayne 07-26-2013 08:38 AM

PostgreSQL Locale Problem Slackware 64 Stable
 
I need to create a data base in PostgreSQL:
Code:

createdb -U dspace -E UNICODE dspace
createdb: database creation failed: ERROR:  encoding "UTF8" does not match locale "en_US"
DETAIL:  The chosen LC_CTYPE setting requires encoding "LATIN1".

I have the system locale set
Code:

locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE=C
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=

Trying
Code:

export LC_CTYPE="LATIN1"
didn't do diddly squat and neither has anything else I've fiddled with (in /etc/profile.d/lang.sh, I have
Code:

export LANG=en_US.UTF-8
and
export LC_COLLATE=C

defined, nothing else).

Anybody got any ideas how to get the PostgreSQL data base created with the required encoding?

mfrias 07-26-2013 09:42 AM

Quote:

Originally Posted by tronayne (Post 4997215)
...
Code:

export LANG=en_US.UTF-8
and
export LC_COLLATE=C

...

The error is in LC_LOCATE, initdb must be initialized with the correct LC_LOCATE. LC_LOCATE must be configured and be equal to the rest of the other variables.

http://www.postgresql.org/docs/9.2/s...multibyte.html

tronayne 07-26-2013 10:06 AM

@mfrias, thank you for the reply. Just before I read it, I had figured out that the problem was that the system was installed with the Slackware default locale and that PostgreSQL had been installed and initialized with that locale (which is LANG=en_US, not LANG=en_US.UTF-8). OK, blow away everything in /var/lib/pgsql, re-initialize, createuser, createdb and all is well that ends.

Lesson learned: if you're going to need to use UNICODE (at least for PostgreSQL), define that at system set up.

Thank you again.

torimus 07-26-2013 03:32 PM

You need not to do it this way. You can simply pass proper parameters to create database command like
Code:

create database <your_db_name> encoding='UTF8' LC_COLLATE='<your_locale>.UTF-8' LC_CTYPE='<your_locale>.UTF-8' template template0;


All times are GMT -5. The time now is 06:54 AM.