/var/lib/pgsql/data
) in which the databases of all PostgreSQL installations are stored.lower()
function, lower()
the Cyrillic text did not occur, while the English values ​​readily "decreased".UTF-8
(in my case, by mistake, it was in default SQL_ASCII
).[bash] # su - postgres ~ vacuumdb --full --analyze --username postgres --dbname mydatabase ~ pg_dump mydatabase -Ft -v -U postgres -f /tmp/mydatabase.tar ~ dropdb mydatabase --username postgres ~ createdb --encoding UNICODE mydatabase --username postgres ~ pg_restore /tmp/mydatabase.tar | psql --dbname mydatabase --username postgres ~ vacuumdb --full --analyze --username postgres --dbname mydatabase
lower()
function still did not occur.lower()
and upper()
this means a lot!crontab
) once an hour. The good thing is that it is not so much a production that there would be no free “window” for re-initialization.pg_drop
swore at the connected users to the same databases (it was decided to close pgAdmin )./usr/lib/postgresql/8.3/bin
) command ( initdb
) and executed with the necessary parameters.[bash] # su - postgres ~ vacuumdb --full --analyze --username postgres --dbname mydatabase ~ pg_dump mydatabase -Ft -v -U postgres -f /tmp/mydatabase.tar ~ dropdb mydatabase --username postgres ~ initdb --locale = en_RU.utf8 data /
A warning! Do not immediatelyrm -rf data/*
. I realized this after I did it on the laptop, and after the recovery, I lost the user access rights to the server (which are stored inpg_hba.conf
).
pg_hba.conf
somewhere for the duration of the change.[bash] ~ cp data / pg_hba.conf /home/cr0t/pg_hba.2009.03.24_1654.conf
[bash] ~ exit # /etc/init.d/postgresql stop # su - postgres ~ rm -rf data / * ~ initdb --locale = en_RU.utf8 data /
[bash] ~ exit # /etc/init.d/postgresql start # su - postgres ~ createdb --encoding UNICODE mydatabase --username postgres ~ pg_restore /tmp/mydatabase.tar | psql --dbname mydatabase --username postgres ~ vacuumdb --full --analyze --username postgres --dbname mydatabase
lower()
function began to correctly “press” Cyrillic characters. Everyone is happy. But I didn’t even think about the user roles of PostgreSQL (this is how users in the 8.x version became known). They are gone. Good thing I needed to create a whole couple of them. But who has a lot of them, be careful, do not repeat my mistakes![bash] # su - postgres ~ vacuumdb --full --analyze --username postgres --dbname mydb1 ~ pg_dump mydb1 -Ft -v -U postgres -f /tmp/mydb1.tar ~ dropdb mydb1 --username postgres ~ vacuumdb --full --analyze --username postgres --dbname mydb2 ~ pg_dump mydb2 -Ft -v -U postgres -f /tmp/mydb2.tar ~ dropdb mydb2 --username postgres ~ vacuumdb --full --analyze --username postgres --dbname mydb3 ~ pg_dump mydb3 -Ft -v -U postgres -f /tmp/mydb3.tar ~ dropdb mydb3 --username postgres ~ cp data / pg_hba.conf ./ ~ exit # /etc/init.d/postgresql stop # su - postgres ~ rm -rf data / * ~ initdb --locale = en_RU.utf8 data / ~ cp pg_hba.conf data / ~ exit # /etc/init.d/postgresql start # su - postgres ~ createdb --encoding UNICODE mydb1 --username postgres ~ pg_restore /tmp/mydb1.tar | psql --dbname mydb1 --username postgres ~ vacuumdb --full --analyze --username postgres --dbname mydb1 ~ createdb --encoding UNICODE mydb2 --username postgres ~ pg_restore /tmp/mydb2.tar | psql --dbname mydb2 --username postgres ~ vacuumdb --full --analyze --username postgres --dbname mydb2 ~ createdb --encoding UNICODE mydb3 --username postgres ~ pg_restore /tmp/mydb3.tar | psql --dbname mydb3 --username postgres ~ vacuumdb --full --analyze --username postgres --dbname mydb3
Source: https://habr.com/ru/post/55620/
All Articles