POSTGRES IMPORT AND EXPORT DATABASE

Create postgres database using command line:-

createdb -h localhost -p 5432 -U postgres databasename

Import database

psql -h localhost -U username -d databasename -f /filepath/filename.sql

Or for dump file extension:-

pg_restore -U username -d dbname -1 filename.dump

or

pg_restore -h localhost -U root -W -F t -d databasename database_dump_file.tar 

or

pg_restore -h localhost -p 5432 -U postgres -d databasename -v "pro.dump"

https://stackoverflow.com/questions/2732474/restore-a-postgres-backup-file-using-the-command-line

Export database

pg_dump -U postgres databasename > filename.sql

When we are getting error like

When we get error at the time of import the postgres database :-

: FATAL:  Peer authentication failed for user "postgres"

then:-

The problem is still your pg_hba.conf file (/etc/postgresql/9.1/main/pg_hba.conf). This line:

local   all             postgres                                peer

Should be

local   all             postgres                                md5
After altering this file, don't forget to restart your PostgreSQL server. If you're on Linux, that would be 

sudo service postgresql restart

http://stackoverflow.com/questions/18664074/getting-error-peer-authentication-failed-for-user-postgres-when-trying-to-ge


WE CAN REFER:-

https://www.a2hosting.in/kb/developer-corner/postgresql/import-and-export-a-postgresql-database
Post a Comment

Popular posts from this blog

CARRIERWAVE - UPLOAD ANY MEDIA (AUDIO , VIDEO AND IMAGE ) FILE IN RAILS

RAILS: UPLOADING PHOTOS VIA AMAZON S3 AND PAPERCLIP (UPLOADING FILES TO S3 IN RUBY WITH PAPERCLIP)

SELECT COUNTRY WITH STATE AND IT'S CITIES RAILS

UNINITIALIZED CONSTANT PAPERCLIP::STORAGE::S3::AWS

Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension.

HOW TO CALL RAILS API FROM SIMPLE HTML PAGE.

CREATE API FOR USER SIGN UP, LOGIN AND CREATE PUBLISHER WITH CURRENT USER