Difference between revisions of "Import PostgreSQL Database Dump File"

From Gejoreuy
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
https://www.compose.com/articles/postgresql-tips-installing-the-postgresql-client/
 
<br>https://www.alibabacloud.com/help/doc-detail/96785.htm
 
 
 
== Purpose ==
 
== Purpose ==
  
Line 7: Line 4:
  
 
== Import the Dump File ==
 
== Import the Dump File ==
 +
 +
Just run below command and change it with the database value.
  
 
<pre>
 
<pre>
[root@gejoreuy ~]# psql -U username -h hostname -d desintationdb -p port -f dumpfilename.sql
+
[root@gejoreuy ~]# psql -U username -h hostname -d destinationdb -p port -f dumpfilename.sql
 
</pre>
 
</pre>
  
 
Note :
 
Note :
<br>username: The username to log on to the ApsaraDB RDS for PostgreSQL database.
+
* username: The username to log on to PostgreSQL database.
<br>hostname: The hostname of the ApsaraDB RDS for PostgreSQL database.
+
* hostname: The hostname of the PostgreSQL database.
<br>port: The port number of the ApsaraDB RDS for PostgreSQL database.
+
* port: The port number of the PostgreSQL database.
<br>desintationdb: The ApsaraDB RDS for PostgreSQL database name.
+
* destinationdb: The PostgreSQL database name.
<br>dumpfilename: The name of the backup file to be restored.
+
* dumpfilename: The name of the backup file to be restored.

Latest revision as of 21:47, 9 January 2020

Purpose

This topic describes how to use the psql command to restore the PostgreSQL data backup files to PostGreSQL DB.

Import the Dump File

Just run below command and change it with the database value.

[root@gejoreuy ~]# psql -U username -h hostname -d destinationdb -p port -f dumpfilename.sql

Note :

  • username: The username to log on to PostgreSQL database.
  • hostname: The hostname of the PostgreSQL database.
  • port: The port number of the PostgreSQL database.
  • destinationdb: The PostgreSQL database name.
  • dumpfilename: The name of the backup file to be restored.