如何在PgSQL中将数据库从一台服务器移动到另一台服务器?

时间:2022-11-15 20:48:19

I am trying to move a database from my old server to a new server. Any help would be appreciated.

我正在尝试将数据库从旧服务器移动到新服务器。任何帮助,将不胜感激。

2 个解决方案

#1


8  

Just pipe a dump from the old server into the new one:

只需将旧服务器的转储管道传输到新服务器:

pg_dump -h 172.26.76.100 -p 5432 -U username your_db | psql -h localhost -p 5432 -U username your_db 

Replace the ip addresses and there you go. If you're using different versions of PostgreSQL, make sure you use pg_dump and psql from the latest version.

替换IP地址,然后你去。如果您使用的是不同版本的PostgreSQL,请确保使用最新版本的pg_dump和psql。

#2


2  

Dump it on the first server and restore it on the second, using either the command line tools or something loke pgAdmin.

将它转储到第一台服务器上,然后使用命令行工具或loke pgAdmin将其恢复到第二台服务器上。

#1


8  

Just pipe a dump from the old server into the new one:

只需将旧服务器的转储管道传输到新服务器:

pg_dump -h 172.26.76.100 -p 5432 -U username your_db | psql -h localhost -p 5432 -U username your_db 

Replace the ip addresses and there you go. If you're using different versions of PostgreSQL, make sure you use pg_dump and psql from the latest version.

替换IP地址,然后你去。如果您使用的是不同版本的PostgreSQL,请确保使用最新版本的pg_dump和psql。

#2


2  

Dump it on the first server and restore it on the second, using either the command line tools or something loke pgAdmin.

将它转储到第一台服务器上,然后使用命令行工具或loke pgAdmin将其恢复到第二台服务器上。