Last active
February 19, 2018 23:45
-
-
Save vmwsree/4582424db5a3e385a1a31c0a7ef94595 to your computer and use it in GitHub Desktop.
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
sudo su - postgres | |
\password Change your password | |
\q Exit psql | |
\l List all databases accessible by the current account | |
\du List roles | |
\c <db name> Connect to a database | |
\dt List all tables in a connected database | |
\d <table> List columns in the selected table | |
\conninfo Show information about your currect connection | |
\q | |
createuser --interactive | |
createdb <database name> | |
psql | |
ALTER DATABASE <database name> OWNER TO <role name>; | |
ALTER USER <username> WITH PASSWORD '<new password>'; | |
======= | |
> pg_dump -h <server> -p 5432 -U <username> <database> > <local file> | |
Restoring your database is also as simple with a single command: | |
> psql -h <server> -U <username> -d <database> < <local file> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment