Перейти к содержанию

03.postgresql

Install PostgreSQL

apt install -y postgresql
su -l postgres
psql
DROP DATABASE IF EXISTS rbt;
DROP USER IF EXISTS rbt;
CREATE DATABASE rbt;
CREATE USER rbt WITH ENCRYPTED PASSWORD 'rbt';
GRANT ALL ON DATABASE rbt TO rbt;
\c rbt;
GRANT ALL ON SCHEMA public TO rbt;
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;

Changing the scheme (only if you understand exactly what it is and why)

CREATE SCHEMA <!---YOUR SCHEMA-->;
GRANT ALL ON SCHEMA <!---YOUR SCHEMA--> TO rbt;

Upgrade PostgreSQL (only if you understand exactly what it is and why)

su -l postgres
pg_dropcluster <NEWVERSION> main --stop
pg_upgradecluster <OLDVERSION> main
pg_dropcluster <OLDVERSION> main
apt-get purge postgresql-<OLDVERSION> postgresql-client-<OLDVERSION>
systemctl restart postgresql

Sometimes updating collation is required

CREATE COLLATION <!-- YOUR COLLATION (for example: russian) --> (provider = libc, locale = '<!-- YOUR LOCALE (for example: ru_RU.utf8) -->');
ALTER DATABASE rbt REFRESH COLLATION VERSION;

Next