Export and Import PostgreSQL

Praaveen Vr
praaveen
Published in
2 min readDec 17, 2021

--

Export a PostgreSQL database dump using pg_dump

Extract a PostgreSQL database into a script file or other archive file.pg_dump is a utility for backing up a PostgreSQL database

Import a PostgreSQL database dump using pg_restore and psql

a. pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats.
b. psql for restoring from a plain SQL script file.

This blog help us to know in details

postgres db and user setup

After installing the PostgreSQL, most of the time we stuck with error called Peer authentication failed for user postgres , when trying to get pgsql working with rails

Solution:

Switching between the authentication methods trust and md5.

This link help us to know in details

Trust Authentication

When trust authentication is specified, PostgreSQL assumes that anyone who can connect to the server is authorized to access the database with whatever database user name they specify (even superuser names). Of course, restrictions made in the database and user columns still apply. This method should only be used when there is adequate operating-system-level protection on connections to the server.

Password Authentication

The password-based authentication methods are md5 and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively.

--

--