Last active
December 11, 2015 20:49
-
-
Save yaph/4658140 to your computer and use it in GitHub Desktop.
Frequently used commands when working with postgresql databases on Ubuntu, like creating and deleting databases and users. https://help.ubuntu.com/community/PostgreSQL
This file contains hidden or 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
# create user and database with user as admin | |
sudo -u postgres createuser -D -A -P uname | |
sudo -u postgres createdb -O uname dbname | |
# delete database and user | |
sudo -u postgres dropdb dbname | |
sudo -u postgres dropuser uname | |
# dump and import data | |
pg_dump --clean -U uname dbname > dump.sql | |
psql --password -U uname dbname < dump.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment