如何使用PSQL创建Postgres数据库的SQL转储文件

发布于 2025-01-29 02:07:47 字数 640 浏览 4 评论 0原文

我目前已经通过Supabase创建了一个数据库,该数据库使用Postgres数据库。这样做之后,我在计算机上下载了Postgres,这给了我PSQL命令行脚本,用于连接到Postgres数据库。

我打算通过PSQL脚本创建Supabase数据库的本地备份。 之后,我已经连接到supabase数据库之后

这是在我通过psql ”命令显示了supabase数据库内的表“

,我可以看到PSQL成功地连接到数据库。

然后,我尝试使用pg_dump命令来尝试创建数据库的转储文件。 这是我使用的命令:

pg_dump postgresql:// postgres:[数据库密码]@db.epvzhrganrzfwexmiksg.supabase.co:5432/postgres> 但是, dumpfile.sql

但是,在我按ENTER之后,PSQL没有运行命令,它只是移动到新的命令行。因此,我不确定是否输入了转储命令的错误,还是我需要使用的其他PSQL命令。

I currently have created a database via Supabase, which uses the Postgres database. After doing so, I then downloaded Postgres on my computer, which gave me the psql command line script for use to connect to postgres databases.

I intend to create a local backup of my Supabase database through the psql script.
This is after I have connected to the supabase database through psql

Command that shows tables inside the supabase database

From this, i can see that psql successfully connected to the database.

I then tried to use the pg_dump command to attempt to create a dump file of the database.
This was the command I used:

pg_dump postgresql://postgres:[Database password]@db.epvzhrganrzfwexmiksg.supabase.co:5432/postgres > dumpfile.sql

However, after I pressed enter, psql did not run the command, it simply moved to a new command line. As such, I am not sure whether I inputted something wrong for the dump command or is it a different psql command I need to use for it.

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

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

发布评论

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

评论(2

你丑哭了我 2025-02-05 02:07:47

如前所述,您已成功与PSQL联系。

  • 以下是如果您具有OS提示符访问权限,则可以采取普通的.sql备份。

来自OS提示

$ pg_dump mydb > mydb.sql

psql提示

postgres# \! pg_dump mydb > mydb.sql

发布备份,MyDB.SQL文件可以复制&通过PSQL导入到本地机器。

As mentioned, you have successfully connected with psql.

  • Below are the steps to take plain .sql backup, if you have the OS prompt access.

From OS prompt

$ pg_dump mydb > mydb.sql

From psql prompt

postgres# \! pg_dump mydb > mydb.sql

Post backup done , mydb.sql file can be copied & import via psql to local machine.

汹涌人海 2025-02-05 02:07:47

如 @adrian -klaver所述,pg_dump命令应直接从终端运行,而不是从psql shell

运行pg_dump -v内部运行。通常安装PSQL https://stackoverflow.com/a/a/49689589/1267728

as mentioned by @adrian-klaver the pg_dump command should be run directly from the terminal, and not from inside the psql shell

run pg_dump -V to check that it's installed. It is usually installed when you install psql https://stackoverflow.com/a/49689589/1267728

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