且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何 pg_dump RDS Postgres 数据库?

更新时间:2023-02-02 20:35:32

步骤 1:在 AWS 上创建一个安全组,将您的计算机的 IP 地址列入白名单.

Step 1: Create a security group on AWS that has your computer's IP address white listed.

第 2 步:将该安全组添加到您要连接的数据库实例.

Step 2: Add that security group to the database instance you want to connect to.

第 3 步:运行 pg_dump.确保使用 -U 命令指定您的用户名(感谢 @LHWizard).在这种情况下,我的不是postgres",所以我想通常你必须查看 aws 才能找到它.还要确保指定您的数据库名称:在某些命令行工具中,有一个 -d 开关,但是如果您检查 pg_dump 的用法:

Step 3: Run pg_dump. Make sure to specify your user name (thanks @LHWizard) with the -U command. In this case mine wasn't 'postgres', so I guess generally you'll have to look in aws to find it. Also make sure to specify your database's name: in some command line tools there's a -d switch for that, but if you check pg_dump's usage:

Usage:
  pg_dump [OPTION]... [DBNAME]

你可以看到这是一个正式的论证.所以整个命令(就我而言)是:

you can see that it's a formal argument. So the whole command (in my case) was:

pg_dump -h <public dns> -U <my username> -f dump.sql <name of my database>

请注意,没有必要指定端口号——我认为是因为端口 5432 是 postgres 的端口.

Notice that specifying the port number wasn't necessary -- I think because port 5432 is THE port for postgres.