Today most of my sites stopped to work. After some time I've noticed that PostgreSQL has some problem with locale:
psql: FATAL: database locale is incompatible with operating system DETAIL: The database was initialized with LC_COLLATE "pl_PL.UTF-8", which is not recognized by setlocale(). HINT: Recreate the database with another locale or install the missing locale.
I've found similar symptoms in thread "Problem with locales on Linux with 9.3.4" posted by Hubert "depesz" Lubaczewski.
My databases has collation pl_PL.UTF-8:
List of databases Name | Owner | Encoding | Collation | Ctype | Access privileges --------------------+--------------------+----------+-------------+-------------+----------------------- eztest-demo | xxxxxxxx | UTF8 | pl_PL.UTF-8 | pl_PL.UTF-8 | eztest-flow | xxxxxxxx | UTF8 | pl_PL.UTF-8 | pl_PL.UTF-8 | eztest-web | xxxxxxxx | UTF8 | pl_PL.UTF-8 | pl_PL.UTF-8 |
and this locale was installed:
[root@jaqb ~]# locale -a | grep pl pl_PL pl_PL.iso88592 pl_PL.utf8
The solution: Restart PostgreSQL ;-)
[root@jaqb ~]# /etc/init.d/postgresql restart Stopping postgresql service: [ OK ] Starting postgresql service: [ OK ] [root@jaqb ~]# psql eztest-web psql (8.4.20) Type "help" for help. eztest-web=>
That's all.
Dawno tego nie robiłem, więc już zapomniałem co począć ze świeżo zaistalowanym serwerem PostgreSQL'a. To to pokolei:
inicjuję bazę
/etc/init.d/postgresql initdb
podłączam się do bazy
su - postgres -c psql template1
taka konstrukacja to dla tego, że użytkownik root nie ma dostępu do bazy
zakładam użytkowninka
CREATE USER firstuser;
ustawiam mu hasło
ALTER USER firstuser PASSWORD 'jegohaslo';
zakładam bazę
CREATE DATABASE firstdb WITH OWNER firstuser \ TEMPLATE template0 \ LC_COLLATE 'pl_PL.UTF-8' \ LC_CTYPE 'pl_PL.UTF-8';
Zamiast tworzyć użytkowników i bazy z poziomu użytkownika postgres można zmienić w pliku /var/lib/pgsql/data/pg_hba.conf metodę autoryzacji z ident na trust w wierszu
host all all 127.0.0.1/32 ident
,ale to rozwiązanie nie jest bezpieczne, bo autoryzuje każdego użytkownika podłączającego się lokalnie. Docelowo można zmienić metodę autoryzacji na md5.
Żeby wymusić połączenie po IP a nie po gniazdach (ang. socket) można dodać parametr -h localhost.
Add comment