Skip to content

Instantly share code, notes, and snippets.

@illia108
Last active December 23, 2017 13:13
Show Gist options
  • Save illia108/912fc2b35fc78c349219cb4d376cab18 to your computer and use it in GitHub Desktop.
Save illia108/912fc2b35fc78c349219cb4d376cab18 to your computer and use it in GitHub Desktop.

run shell - sudo -u [as user. default - postgres] psql postgres

create user for rails app - CREATE ROLE [name] WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'password';

list all users - \du

set password - \password

list all databases - \l

use (connect) DB - \c db_name

drop DB - DROP DATABASE db_name;

drop user - DROP USER user_name;

quit - \q

copy data from one DB to another (NOT in postgres) - pg_dump -U illia hiker_development | psql -U illia hiker_production

restart postgreSQL - /etc/init.d/postgresql restart

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