Last active
December 20, 2015 03:09
-
-
Save sepastian/6061580 to your computer and use it in GitHub Desktop.
Restore a binary dump in 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
# In /etc/postgresql/9.1/main/pg_hba.conf, change | |
# | |
# local all all peer | |
# | |
# to | |
# | |
# local all all md5 | |
# | |
# and restart the Postgres server: | |
$ sudo service postgresql restart | |
# Become psql to create a user/database | |
$ sudo -i | |
$ su - postgres | |
# Create a database user and a database. | |
# The database user will be the owner of the database. | |
# createuser will ask for a password for the new user. | |
$ createuser -D -P DB_USER_NAME | |
$ createdb -O DB_USER_NAME DATABASE_NAME | |
# Try logging into the new database. | |
$ psql -U DB_USER_NAME -d DATABASE_NAME | |
# Logout. | |
# As a normal user, use pg_restore to import the datadump. | |
pg_restore -U DB_USER_NAME -d DATABASE_NAME PATH_TO_DUMP_FILE | |
# Login again and list the tables restored. | |
psql -U DB_USER_NAME -d DATABASE_NAME | |
DATABASE_NAME=> \d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment