Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres locale error

I have a Postgres database hosted on Digital River, on Ubuntu, and followed these instructions to install:

But something is wrong with the locale settings and I cannot work out how to fix it. When I run the psql command I get the following error:

postgres@assay:/home/deployer$ psql
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
psql (9.1.9)
like image 221
port5432 Avatar asked Jul 17 '13 14:07

port5432


People also ask

What is locale in Postgres?

Locale support refers to an application respecting cultural preferences regarding alphabets, sorting, number formatting, etc. PostgreSQL uses the standard ISO C and POSIX locale facilities provided by the server operating system. For additional information refer to the documentation of your system.

How do I find my locale Postgres?

To check what locales are installed on your system, you may use the command locale -a if your operating system provides it. Check that PostgreSQL is actually using the locale that you think it is. LC_COLLATE and LC_CTYPE settings are determined at initdb time and cannot be changed without repeating initdb.

What is Initdb in PostgreSQL?

initdb initializes the database cluster's default locale and character set encoding. The character set encoding, collation order ( LC_COLLATE ) and character set classes ( LC_CTYPE , e.g., upper, lower, digit) can be set separately for a database when it is created.


2 Answers

Thank you very much to Kamal Nasser on the Digital River forums for providing the correct answer (the following commands below requires root privileges):

$ locale-gen en_US en_US.UTF-8 
$ dpkg-reconfigure locales

I think this is the correct link to the original answer: the Digital Ocean site is not responding so I can't check it. https://www.digitalocean.com/community/questions/postgresql-and-rails-4

like image 73
port5432 Avatar answered Sep 18 '22 15:09

port5432


After trying ardochhigh's answer:

$ sudo locale-gen en_US en_US.UTF-8 
$ sudo dpkg-reconfigure locales

the problem persisted

After that I saw this answer that solved the problem for me:

https://www.digitalocean.com/community/questions/language-problem-on-ubuntu-14-04

Aparently LAGUAGE shell variable is not set:

$ sudo bash

$ export LANGUAGE="en_US.UTF-8"
$ echo 'LANGUAGE="en_US.UTF-8"' >> /etc/default/locale
$ echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale

$ # next: logout and login
like image 20
João Reis Avatar answered Sep 16 '22 15:09

João Reis