Last active
August 29, 2015 14:17
-
-
Save ryantbrown/0d2833f1f4df3f1b51a2 to your computer and use it in GitHub Desktop.
Postgres Administration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# command line: | |
sudo -u postgres createuser --superuser username | |
sudo -u postgres createdb -O vagrant dbname | |
# enter shell | |
psql dbname username | |
# list users: | |
\du | |
#list databases: | |
\list | |
# exit shell: | |
\q | |
# manaing roles (users) | |
CREATE USER username WITH PASSWORD 'password' | |
ALTER ROLE username WITH PASSWORD 'vagrant'; | |
DROP ROLE username; | |
# WITH options | |
SUPERUSER | NOSUPERUSER | |
CREATEDB | NOCREATEDB | |
CREATEROLE | NOCREATEROLE | |
CREATEUSER | NOCREATEUSER | |
PASSWORD 'password' | |
# managing databases | |
CREATE DATABASE dbname OWNER username; | |
DROP DATABASE IF EXISTS dbname; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment