如何为托管在AWS上的PostgreSQL数据库执行SQL脚本?

发布于 2025-01-21 06:51:21 字数 496 浏览 0 评论 0原文

我正在尝试运行一个在AWS RDS上托管的数据库的SQL文件。我使用的命令是以下内容:

psql -v user=myusername -v dbname=postgres -v passwd=mypassword -f ./explorerpg.sql

运行后,我得到以下结果:

sql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我缺少什么?对于那些好奇的人,我试图让Hyperledger Explorer显示AWS区块链的数据库内容。 SQL脚本来自Hyperledger Explorer。

任何建议都非常感谢!

I am trying to run an sql file for a database hosted on AWS RDS. The command I am using is the following:

psql -v user=myusername -v dbname=postgres -v passwd=mypassword -f ./explorerpg.sql

After running it I get the following result:

sql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

What am I missing? For those curious I am trying to get Hyperledger explorer to display the database contents of an AWS blockchain. The sql script is from Hyperledger explorer.

Any suggestions are greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此生挚爱伱 2025-01-28 06:51:21

您缺少-h(或- 主机)选项。您正在运行的命令正在尝试连接到Localhost上的PostgreSQL Server。此外,您正在尝试使用命令行进行努力。您想要更多类似的东西:

psql -U myusername -d postgres -h dbhostname.randomcharacters.us-west-2.rds.amazonaws.com -v passwd=mypassword -f ./explorerpg.sql

可能不应该这样做密码 - 包含密码的文件更常见。但是,关键是要找到RDS服务器的主机名,并使用-H选项指定它。

You're missing the -h (or --host) option. The command you're running is trying to connect to a PostgreSQL server on your localhost. Additionally, you're trying too hard with the command line. You want something more like:

psql -U myusername -d postgres -h dbhostname.randomcharacters.us-west-2.rds.amazonaws.com -v passwd=mypassword -f ./explorerpg.sql

The password likely should not be done this way - a file containing the password is more common. But the key is to find the hostname of your RDS server and specify it with the -h option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文