- Install PostgreSQL database (
apt install postgresql postgresql-contrib
under Ubuntu) - Log in to the postgres account:
sudo --login --user postgres
- Start the PostgreSQL interactive terminal:
psql
- Create the database:
postgres=# CREATE DATABASE my_database;
- Create a user:
postgres=# CREATE USER my_user WITH PASSWORD 'my_password';
- Grant the user access to the database.
postgres=# GRANT ALL PRIVILEGES ON DATABASE my_database to my_user;
- Switch to the database:
\connect my_database;
- Enable ltree extension on the database:
create extension ltree;
- Exit psql:
\q
Created
June 22, 2018 19:08
-
-
Save jobliz/439da26f67fe48494ffdffd86b275834 to your computer and use it in GitHub Desktop.
PostgreSQL database configuration with ltree extension
If you want to run DROP SCHEMA public
and/or CREATE SCHEMA public;
you must set the created user as owner of the schema with:
ALTER SCHEMA public OWNER TO
my_user;`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Django to create test databases you also need to do
ALTER USER my_user CREATEDB;
inside psql.