I am using Postgres via a vagrant instance running ubuntu-xenial-16.04-cloudimg box and I have an sql dump from another developer.
By the way, I tried using PGAdmin IV from my Win 10 host machine after I had connected to the Postgres server on the virtualbox (ubuntu) but it takes forever and not running.
How can I import this to the Postgres running on virtualbox instance?
So given an sql dump file as dump.sql
.
vagrant ssh
on an ssh client like git bash(for windows) vagrant rsync
, just to make sure. cd ../../
for an ubuntu guest on a window host) psql -h hostname -U test -d databasename -f dump.sql
. Depending on the format of the dump (normal or custom), you can use psql
or pg_restore
. Check the --format
option in the documentation for pg_dump
Following the simple steps below solves my problem:
vagrant up
, vagrant ssh
to log into the os psql
command create database your_db_name
to create the empty db your_db_name -f /path/to/the/dump.sql
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.