如何将数据从Windows上的postgres移动到Linux上的postgres(Ubuntu)

如何将数据从Windows上的postgres移动到Linux上的postgres(Ubuntu)

问题描述:

我在Windows操作系统上安装了Postgres数据库,同时我还使用Linux(Ubuntu)虚拟机。我需要将数据从Windows移到Linux。 在此先感谢!如何将数据从Windows上的postgres移动到Linux上的postgres(Ubuntu)

+0

备份一起使用 - 恢复? – lad2025

+1

是的,备份和恢复:https://www.sqlshack.com/migrate-an-sql-database-from-windows-to-linux-using-backup-and-restore-and-smb-protocol/ – Lucas

您可以使用下面的查询从一台服务器将数据库还原到另一个

pg_dump -C -h SourceServer -U SourceUser SourceDB | psql -h TargetHost -U TargetUser TargetDB 

密码可以从pgpass.conf