gpt4 book ai didi

postgresql - 为什么 pg_restore 返回 "options -d/--dbname and -f/--file cannot be used together"?

转载 作者:行者123 更新时间:2023-11-29 11:27:37 25 4
gpt4 key购买 nike

以下 Windows 批处理脚本在数据库恢复行失败:

@Echo off

set Path=C:\Program Files (x86)
set Backup_Path=C:\Program Files (x86)

c:
cd \
cd C:\Program Files (x86)\PostgreSQL\9.1\bin

@echo "Wait ..."
setlocal
set PGPASSWORD=1234
psql.exe -U postgres -c "create database Mydata"
"C:\Program Files (x86)\PostgreSQL\9.1\bin\pg_restore.exe" -h localhost -U postgres -d Mydata -f "Mydata.backup"

pause
endlocal

错误是:

pg_restore : -d / - dbname and -f / - file can not be used together Try " pg_restore --help "

最佳答案

-f输出 文件名,而不是输入文件。

输入文件没有任何参数切换。

c:\>pg_restore --help
pg_restore restores a PostgreSQL database from an archive created by pg_dump.

Usage:
pg_restore [OPTION]... [FILE]

General options:
-d, --dbname=NAME connect to database name
-f, --file=FILENAME output file name
-F, --format=c|d|t backup file format (should be automatic)
-l, --list print summarized TOC of the archive
-v, --verbose verbose mode
-V, --version output version information, then exit
-?, --help show this help, then exit

所以你需要使用:

pg_restore.exe -h localhost -U postgres -d Mydata "Mydata.backup"

手册中有更多详细信息:http://www.postgresql.org/docs/current/static/app-pgrestore.html

关于postgresql - 为什么 pg_restore 返回 "options -d/--dbname and -f/--file cannot be used together"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27882070/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com