postgresql pg_dump:命令行参数太多

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11865596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 23:39:25  来源:igfitidea点击:

pg_dump: too many command line arguments

postgresqldumpdatabase-backupspg-dump

提问by Bhargav Gor

what is wrong with this command:

这个命令有什么问题:

pg_dump -U postgres -W admin --disable-triggers -a -t employees -f D:\ddd.txt postgres

This is giving error of too many command-line arguments

这给出了太多命令行参数的错误

回答by Jim

Looks like its the -W option. There is no value to go with that option.

看起来像是 -W 选项。该选项没有任何价值。

-W, --password           force password prompt (should happen automatically)

If you want to run the command without typing is a password, use a .pgpass file. http://www.postgresql.org/docs/9.1/static/libpq-pgpass.html

如果您想在不输入密码的情况下运行该命令,请使用 .pgpass 文件。 http://www.postgresql.org/docs/9.1/static/libpq-pgpass.html

回答by johnkaplantech

For posterity, note that pg_dump and pg_restore (and many other commands) cannot process long hyphens that word processors create. If you are cut-pasting command lines from a word processor, be sure it hasn't converted your hyphens to something else in editing. Else you will get command lines that look correct but hopelessly confuse the argument parsers in these tools.

对于后代,请注意 pg_dump 和 pg_restore(以及许多其他命令)无法处理文字处理器创建的长连字符。如果您从文字处理器中剪切粘贴命令行,请确保它没有将您的连字符转换为编辑中的其他内容。否则,您将获得看起来正确但无望地混淆这些工具中的参数解析器的命令行。

回答by Frederik Struck-Sch?ning

I got this from copy-pasting, where 1 of the dashes were different.

我是从复制粘贴中得到的,其中 1 个破折号不同。

Was: –-host=(first dash i a "long" dash) Corrected to --host=solved it

是:(–-host=第一个破折号是“长”破折号)更正以--host=解决它

回答by Muthu

-W-> will prompt for a password to take full DB dump use some thing like

-W-> 将提示输入密码以进行完整的数据库转储使用类似的东西

pg_dump -h 192.168.44.200 -p 5432 -U postgres -W -c -C -Fc -f C:\MMM\backup10_3.backup DATABASE_NAME

回答by Mustafa Kemal

pg_dump and pg_restore need to ask password on commanline, if you put it command, they always give "too many command-line arguments" error. You can use below for setting related environment variable in commandline or batch file:

pg_dump 和 pg_restore 需要在 commanline 上询问密码,如果你把它放在命令中,他们总是给出“命令行参数太多”的错误。您可以使用以下命令在命令行或批处理文件中设置相关的环境变量:

"SET PGPASSWORD=<password>"

so that you are not asked to enter password manually in your batch file. They use given environment variable.

这样就不会要求您在批处理文件中手动输入密码。他们使用给定的环境变量。

回答by Bartosz

Instead of passing password with -Wflag start with setting temporary variable for postgres:

不是通过-W标志开始传递密码而是为 postgres 设置临时变量:

PGPASSWORD="mypass" pg_dump -U postgres--disable-triggers -a -t employees -f D:\ddd.txt postgres

回答by Szymon Rut

Another option is to add ~/.pgpassfile with content like this:

另一种选择是添加~/.pgpass具有如下内容的文件:

hostname:port:database:username:password

read more here

在这里阅读更多