With the latest “Jessie” Wheezy Debian release on my relatively new R-Pi 2, I was in a hurry to replace my R-Pi original after it failed with a SD card error. Fortunately I was able to recover the config files from the original, as my backups were very much out of date. This system is mail dhcp, dns, mail and asterisk server and it didn’t take a huge amount of time to get everything back together (and faster, too!) but in my haste I did not configure the locale (or the filesystem expansion) in the GUI before I started installing things and got caught with a complaint from PostgreSQL when I tried to connect to the database that it was created with a locale (the default which is Great Britain) instead of the Canadian locale which I’d later configured it to.
Trying the easy stuff first, I removed PostgreSQL and re-installed it but no dice. What worked was the following.
- Change directory to /var/lib/postgresql
- Remove the 9.4 directory and all of its subdirectories and files with rm -rf 9.4
- Log in as user postgres.
- Initialize with initdb (I had to locate the executable as it wasn’t in the default path) with the path 9.4/main/ to recreate the master database (i.e. initdb -D 9.4/main/)
- Restart postgres
Voila! I am now able to connect.