apt-get install postgresql-12sudo -u postgres psqlNote: Command is to be run inside the psql shell
ALTER USER postgres PASSWORD 'myPassword';Note: Command is to be run inside the psql shell
CREATE ROLE jasdeep WITH
LOGIN
SUPERUSER
CREATEDB
CREATEROLE
INHERIT
NOREPLICATION
CONNECTION LIMIT -1
PASSWORD 'xxxxxx';CREATE DATABASE testdb
WITH
OWNER = jasdeep
ENCODING = 'UTF8'
CONNECTION LIMIT = -1;postgres://{db_username}:{db_password}@{host}:{port}/{db_name}
e.g. postgres://jasdeep:password@localhost:5432/testdb
sudo -u postgres psql -lOr inside a psql prompt use \l+:
postgres=# \l+sudo -u postgres psql -d testdb
# Enter into psql with active database
testdb=# \d
testdb=# SELECT * FROM data;Returns
List of relations
Schema | Name | Type | Owner
--------+-------------+----------+---------
public | data | table | jasdeep
public | data_id_seq | sequence | jasdeep
(2 rows)Finally, exit the psql client by using the \q command.
postgres=# \q