Skip to content

Instantly share code, notes, and snippets.

@majidux
Last active July 7, 2021 05:51
Show Gist options
  • Save majidux/171241dead7c9ee1f33894b156d35187 to your computer and use it in GitHub Desktop.
Save majidux/171241dead7c9ee1f33894b156d35187 to your computer and use it in GitHub Desktop.
Here lies docker commands for postgresql
docker pull postgres
// run postgres container
docker run --name mypg -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
// root access to potgres
psql -U postgres
// see roles
\du
// see databases
\l
// create new database in docker
create database DBNAME;
// connect to db
\c DBNAME
// connect to postgres container from local machine
psql -h localhost -p 5432 -U postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment