Skip to content

Instantly share code, notes, and snippets.

@VincentLoy
Last active April 19, 2016 09:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VincentLoy/ae2eef7f8f1af8ec73f9 to your computer and use it in GitHub Desktop.
Save VincentLoy/ae2eef7f8f1af8ec73f9 to your computer and use it in GitHub Desktop.
postgres command memo - migrate here : https://github.com/VincentLoy/alzheimer

Connect as root

$ sudo -u postgres psql

Create new user

postgres=# CREATE USER example WITH PASSWORD 'example';
Change user Password
postgres=# ALTER USER username WITH LOGIN PASSWORD 'new_password';

Grant the user

postgres=# GRANT ALL PRIVILEGES ON DATABASE example to example;

Add extensions

postgis is used as example

postgres=# CREATE EXTENSION IF NOT EXISTS postgis;

Inject an SQL Dump to an existing DB

$ psql your_db_name < /path/to/dump.sql

Postgres URL format

use the following template in every Django projects postgres://username:password@hostname/db_name

To quit just type \q

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