11

I'm trying to connect to psql using the below command but receiving message about unset local setting how could one solve it.

 pi@raspberrypi ~/develop/radar $ psql -U postgres
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
            LANGUAGE = (unset),
            LC_ALL = (unset),
            LC_CTYPE = "UTF-8",
            LANG = "en_GB.UTF-8"
        are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    psql: FATAL:  Peer authentication failed for user "postgres"
Jorge Vidinha
  • 313
  • 1
  • 5
  • 13

5 Answers5

8
  • Run raspi-config.
  • Select 4 Internationalisation Options.
  • Within that submenu, complete:
    • I1 Change Locale
    • I2 Change Timezone

However, the warning from perl about locale is not necessarily the reason you are failing authentication.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
8

I was having a very similar issue. Here's how I fixed it:

Run sudo nano /etc/default/locale

Change it to include these three lines:

LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANGUAGE=en_US.UTF-8

Then reboot the system and it should be updated.

Pikamander2
  • 359
  • 3
  • 10
3

With the new raspbian release Jessie, this can be done easily by just setting the LC_ALL value to C. Here's a link of that solution that i updated on another question. Hope it helps.

giri-sh
  • 787
  • 10
  • 18
3

Scriptable solution:

sudo -i

echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
locale-gen en_US.UTF-8

echo "LANG=en_US.UTF-8" > /etc/default/locale
update-locale en_US.UTF-8
2

I met the same problem when using SSH to connect my PI. I noticed that configuration in PI is different from locale settings in my computer.

I change the /etc/default/locale in BOTH pi and computer to the same, and solved.

Hope it helps to others.

larrydong
  • 21
  • 1