Skip to content

Instantly share code, notes, and snippets.

@cadrev
Forked from schaternik/pg_hba.conf
Last active August 29, 2015 14:25
Show Gist options
  • Save cadrev/71970a62bdfb4e6c92ac to your computer and use it in GitHub Desktop.
Save cadrev/71970a62bdfb4e6c92ac to your computer and use it in GitHub Desktop.
Postgresql

PSQL -- PostgreSQL interactive terminal

sudo -u postgres psql -> postgres=#

CREATE DATABASE test_database;

CREATE USER test_user WITH password 'qwerty';

GRANT ALL privileges ON DATABASE test_database TO test_user;

ALTER USER test_user CREATEDB;

DROP ROLE test_user;

psql -h localhost test_database test_user

PSQL Commands

\?, \h - available psql commands

\d users, \du, \dg - List of roles - description of the 'users' table

\d, \dt - all tables

\list - all DBs

Create, delete & alter users

  • rails new myapp --database=postgresql
  • su - postgres, psql
  • create role alabama_song with createdb login password '1';
  • sudo nano /etc/postgresql/X.Y/main/pg_hba.conf - view config file
  • sudo service postgresql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment