简体   繁体   English

pg_restore:[archiver] 输入文件似乎是文本格式转储。 请使用 psql

[英]pg_restore: [archiver] input file appears to be a text format dump. Please use psql

I was trying to create a new database (analyses_db) on a remote server from a sql file by the command:我试图通过以下命令从 sql 文件在远程服务器上创建一个新数据库 (analyses_db):

pg_restore -d analyses_db byoryn_resource.sql

I received the error message我收到了错误信息

pg_restore: [archiver] input file appears to be a text format dump. pg_restore:[archiver] 输入文件似乎是文本格式转储。 Please use psql.`请使用 psql。`

When I tried to follow the instruction: (from https://stackoverflow.com/a/40632316/15721796 )当我尝试按照说明操作时:(来自https://stackoverflow.com/a/40632316/15721796

To reload such a script into a (freshly created) database named newdb:将这样的脚本重新加载到名为 newdb 的(新创建的)数据库中:
$ psql -d newdb -f db.sql

I received:我收到了:

psql: 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"?

I have no idea how to solve this, as a rookie.作为菜鸟,我不知道如何解决这个问题。 The SQL file should be alright as it is provided.提供的 SQL 文件应该没问题。

After the connection error being solved, I tried the command解决连接错误后,我尝试了命令
sudo -u postgres psql db_name < 'file_path'
(from https://stackoverflow.com/a/26610212/15721796 ) (来自https://stackoverflow.com/a/26610212/15721796
which works just fine.效果很好。
Hope this can help someone who has the same problem.希望这可以帮助有同样问题的人。
Also some useful doc here https://www.postgresql.org/docs/9.1/backup-dump.html这里还有一些有用的文档https://www.postgresql.org/docs/9.1/backup-dump.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pg_restore: [目录归档程序] 无法打开输入文件。 尝试恢复数据库时出错 - pg_restore: [directory archiver] could not open input file. Error while trying to restore DB 调用postgres命令,例如pg_restore或pg_dump形式的sql文件 - Calling postgres command like pg_restore or pg_dump form sql file 在Postgres中,在截断或删除行之后,在pg_dump之前执行reindex是否可以优化pg_restore? - In Postgres, after truncating or deleting rows, does executing reindex before pg_dump optimize pg_restore? PostgreSQL,使用pg_restore更新现有行 - PostgreSQL, update existing rows with pg_restore 使用pg_restore创建或覆盖表 - Using pg_restore to create or overwrite tables 如果 pg_restore 正在进行,我们会在应用程序中遇到任何运行时问题吗? - Will we face any runtime issue in application if pg_restore is in progress? psql恢复sql转储语法错误 - psql restore sql dump syntax error pg_dump:[archiver(db)]与数据库“mydb”的连接失败:致命:数据库“mydb”不存在 - pg_dump: [archiver (db)] connection to database “mydb” failed: FATAL: database “mydb” does not exist 从转储文件中恢复 MySql - Restore MySql from dump file 如何:导入PSQL转储文件? pgAdminConsole或PSQL控制台 - HowTO: Import PSQL dump file ? pgAdminConsole or PSQL console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM