10

For installing postgresql 9.2 I followed this url : http://www.ubuntugeek.com/how-to-install-postgresql-9-2-on-ubuntu-server-using-ppa.html

But at the end of installation output is like :

Setting up postgresql-common (140~precise) ...
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Adding user postgres to group ssl-cert
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql-9.2 (9.2.4-0ppa1~precise) ...
Error: The locale requested by the environment is invalid.
Error: could not create default cluster. Please create it manually with

  pg_createcluster 9.2 main --start

or a similar command (see 'man pg_createcluster').
update-alternatives: using /usr/share/postgresql/9.2/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode.
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

And when I tried to start postgresql, it gives following error :

sudo /etc/init.d/postgresql start
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_MESSAGES = "en_IN.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
 * No PostgreSQL clusters exist; see "man pg_createcluster"

How can I fix this problem ?

Naresh J
  • 2,087
  • 5
  • 26
  • 39

2 Answers2

27

I tried all of the solutions that I could find, but in the end this post sorted it:

http://ubuntuforums.org/showthread.php?t=1720356

Basically, add the language you want to /etc/environment. In my case:

sudo nano /etc/environment

Then added this to the end of the file:

LC_ALL="en_US.utf-8"

Then reboot the server

sudo reboot
Dave Flynn
  • 746
  • 7
  • 6
19

Your system locale configuration is messed up. Your LC_MESSAGES is set to en_IN.UTF-8 but LANG is set to en_US.UTF-8 which is weird and inconsistent. Did you set LC_MESSAGES in your ~/.bash_profile, /etc/environment or something?

You really should dpkg-reconfigure locales. See how to select and generate locales in Ubuntu.

Once you've fixed your locale setup, you can use the pg_wrapper command pg_createcluster 9.2 main --start as suggested by the error to create the cluster. After that, starting the service will work.

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • Before this I installed SDK6 but it didn't gave any error. Then why postgresql gave porblem? – Naresh J Jul 01 '13 at 08:01
  • @NareshJ What is "SDK6"? Do you perhaps mean "the OpenJDK 6 SDK"? The answer is that some programs don't mind so much if your locale configuration is completely broken. PostgreSQL does. **You need to re-generate your locales** so that the locale data for `en_US.UTF-8` and `en_IN.UTF-8` is actually present. – Craig Ringer Jul 01 '13 at 08:03
  • 2
    Hey thank you, I resolved problem by completedly removing postgres and then installed `language-pack-en-base` and then installed postgresql again. It worked. Thank you again for exactly pointing the error. :) – Naresh J Jul 01 '13 at 09:03