Last active
April 2, 2017 13:37
-
-
Save datt/7788238 to your computer and use it in GitHub Desktop.
useful database commands for dump i.e. backup and restore postgresql and mongodb
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
#resetting the password of postgresql | |
sudo -u postgres psql postgres | |
postgres=# \password postgres | |
# restoring postgres dump database | |
pg_restore -c -i -U postgres -h localhost -d database_name -v "dump_file" -W | |
pg_restore --verbose --host localhost --username postgres --clean --no-owner --no-acl --dbname database_name dump_file.dump | |
# for mac: full path is required. | |
Applications/Postgres.app/Contents/Versions/9.4/bin/pg_restore -c -i -U postgres -h localhost -d database_name -v "dump_file" -W | |
# database back up using psql command and with password | |
psql -h localhost -d database_name -U postgres -W > db.sql | |
# database restore using psql command | |
psql -d db_name -f db_dump.sql | |
#Mongo dump restore command. | |
mongorestore --host=127.0.0.1 --port 27017 mongo_dump_path/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment