导出
pg_dump -Fd -h ip地址 -U 用户名 -p 5432 -W 数据库名 -n schema -f 导出的目录名字 -j 2
拷贝文件到远程服务器
scp 目录名/* 用户名@远程ip地址:/远程文件夹路径
scp test/* testuser@10.11.12.13://home/test
导入
pg_restore -v -d 数据库名 -j 2 导入的目录名
pg_restore -v -d testdb -j 2 test
本文介绍如何使用 pg_dump 和 pg_restore 命令进行 PostgreSQL 数据库的导出和导入操作,包括导出数据库到本地文件、将文件传输到远程服务器以及从远程服务器恢复数据库的具体步骤。
导出
pg_dump -Fd -h ip地址 -U 用户名 -p 5432 -W 数据库名 -n schema -f 导出的目录名字 -j 2
拷贝文件到远程服务器
scp 目录名/* 用户名@远程ip地址:/远程文件夹路径
scp test/* testuser@10.11.12.13://home/test
导入
pg_restore -v -d 数据库名 -j 2 导入的目录名
pg_restore -v -d testdb -j 2 test
7817
3万+
6072