21

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)
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
port5432
  • 5,889
  • 10
  • 60
  • 97

2 Answers2

32

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

Tarantula
  • 19,031
  • 12
  • 54
  • 71
port5432
  • 5,889
  • 10
  • 60
  • 97
  • 1
    [Some explanation for this correct answer.](http://stackoverflow.com/questions/17410742/set-order-by-to-ignore-punctuation-on-a-per-column-basis/17412110#17412110) Also, could you add a link to Kamal's answer? – Erwin Brandstetter Jul 18 '13 at 19:42
  • This was what also work for me from 4-5 other similar, but obviously different answers – kmitov Nov 29 '17 at 19:45
14

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
João Reis
  • 423
  • 4
  • 11
  • 5
    Just a note: if you are logged via ssh, the problem could be in your system terminal. Adding these two lines to your `.bashrc` or `.profile` file will made the trick for me and my mate @forons: `export LC_CTYPE=en_US.UTF-8` `export LC_ALL=en_US.UTF-8` – Kuzeko Apr 26 '16 at 13:11
  • @Kuzeko totally! Note if you want to set this for all your users you add the missing env variables in `/etc/environment` like `LC_ALL=en_US.UTF-8`. You might also need to set other variables depending on your error as `LANG`,`LANGUAGE`. – choise Jun 06 '16 at 12:19