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
  • 58,859
  • 17
  • 112
  • 227
  • keep receiving errors such as: /usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory /usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory – Jorge Vidinha Nov 09 '15 at 15:06
  • Yeah, I've seen this one repeatedly over at U&L, but for some people nothing seems to work. I'm sure I've solved it this way before (the manual way, starting by editing locale.gen), but I don't think Raspbian should suffer that problem that way in the first place, particularly if you've run raspi-config. Really it shouldn't blow up like this anywhere though, so worth a check. – goldilocks Nov 09 '15 at 15:19
  • So the standard Debian method dpkg-reconfigure locales and dpkg-reconfigure tzdata aren't supported on Raspbian or what? – 0xC0000022L Nov 01 '17 at 22:46
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
  • 349
  • 3
  • 9
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
  • 777
  • 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