Skip to content

Instantly share code, notes, and snippets.

@Sasha-hk
Created June 6, 2022 20:36
Show Gist options
  • Save Sasha-hk/df40a08f0688b2f9db4563e3acd0f629 to your computer and use it in GitHub Desktop.
Save Sasha-hk/df40a08f0688b2f9db4563e3acd0f629 to your computer and use it in GitHub Desktop.

PostgreSQL on Linux

installation

One of the possible options:

apt install postgresql

Check if postgresql service is run:

systemctl status postgresql

it should return something like this:

● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
     Active: active (exited) since Sun 2022-03-20 22:57:58 EET; 23min ago
   Main PID: 53645 (code=exited, status=0/SUCCESS)
        CPU: 1ms

Mar 20 22:57:58 username systemd[1]: Starting PostgreSQL RDBMS...
Mar 20 22:57:58 username systemd[1]: Finished PostgreSQL RDBMS.

Create database

Connect to postgresql:

runuser -u postgres psql

or

sudo -u postgres

Create databases:

CREATE DATABASE appointment_dev;
CREATE DATABASE appointment_test;
CREATE DATABASE appointment_prod;

Create user:

create user root with encrypted password '1234';

Grant permissions to a new user:

grant all privileges on database appointment_dev to root;
grant all privileges on database appointment_test to root;
grant all privileges on database appointment_prod to root;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment