Skip to content

Instantly share code, notes, and snippets.

@openhubdev
Last active March 3, 2021 20:46
Show Gist options
  • Save openhubdev/37445b246d11d913dbe968d4b2be7d6e to your computer and use it in GitHub Desktop.
Save openhubdev/37445b246d11d913dbe968d4b2be7d6e to your computer and use it in GitHub Desktop.

🐘 Postgres 101

1. Connect to the PostgreSQL

psql postgres or psql postgres -U patrick (as the user "patrick")

2. Create a database

postgres=# CREATE DATABASE djangoblog;

3. Set the access permissions

postgres=> GRANT ALL PRIVILEGES ON DATABASE my_db TO patrick;

To reset the password

postgres=# ALTER USER postgres WITH PASSWORD 'new_password';


useful commands

  • \du: display users | or \du+: display users w details (adds an additional column called description)
  • \list: lists all the databases in Postgres
  • \connect: connect to a specific database
  • \dt: list the tables in the currently connected database
  • \q: quit

HAPPY LEARNING! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment