How to pg_dump an RDS Postgres database?

后端 未结 1 1231
感情败类
感情败类 2020-12-23 08:47

How can I connect to my RDS instance using pg_dump?

This is the instance\'s endpoint:

:5432

So I\'m ru

相关标签:
1条回答
  • 2020-12-23 09:23

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

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

    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>
    

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

    0 讨论(0)
提交回复
热议问题