You are on page 1of 1

To connect to db container bash:

================================
docker exec -it systems-puzzle-master_db_1 bash

Now you are ‘inside’ your container. We can access postgres and create the
database.

connect to postgres sql:


========================
psql -h localhost -p 5432 -U postgres -W
password: postgres

To switch DB:
=============
\c dbname (eg:flaskapp_db)

show list of DB:


================
\l

Quit from db connection


========================
\q (quit)

show list of tables:


=====================
\dt (to show tables)

To exit from container bash:


============================
ctrl + d or exit

create a role/user in postgres sql db:


======================================
createuser --interactive --pwprompt

To show list of user:


=====================
\du (to show list of all users)

to connect to user:dbuser dbname:webserver


==========================================
psql -h localhost -p 5432 --username dbuser --dbname webserver -W

You might also like