【问题标题】:How to run a .sql file with phppgadmin or psql如何使用 phppgadmin 或 psql 运行 .sql 文件
【发布时间】:2016-10-15 04:05:09
【问题描述】:

在 phppgadmin 中导入 .sql 文件时会产生错误

“导入错误:无法自动确定文件格式”。

如何导入文件?

在终端显示为

postgres-# \i Documents/sample.sql

Documents/sample.sql: No such file or directory

但文件存在于特定位置。如何在 Postgresql 和 Phppgadmin 中导入 .sql 文件

【问题讨论】:

  • 支持.sql文件
  • 您的相对路径可能不适用于当前目录。 \i 确实使用 SQL 脚本。尝试提供文件的完整路径。

标签: postgresql phppgadmin


【解决方案1】:

您可以通过命令行执行此操作:

通过命令行使用您的 psql 登录并
只需在终端中运行以下命令

psql 'databasename' < 'database_dump'

只需将“databasename”替换为您的数据库,将“database_dump”替换为您要导入的文件。

【讨论】:

  • 将 "psql 'databasename'
  • 通过使用此代码postgres-# psql postgres
  • 它不会产生任何错误,但会在 phppgadmin 中导入数据
  • 你的数据库叫什么名字?
  • postgres 是数据库的名称
【解决方案2】:

您可以使用以下命令运行文件

psql -U postgres -d postgres -a -f ./test.sql

或者如果你必须通过主机

psql -h -p 5432 -U postgres -d -a -f ./test2.sql

You can refer this bloghttps://trueway-blog.com/run-sql-file-with-psql/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 2021-08-07
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    • 1970-01-01
    相关资源
    最近更新 更多