pg_dump: too many command line arguments

拜拜、爱过 提交于 2019-12-04 15:39:07

问题


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


回答1:


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

-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




回答2:


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.




回答3:


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

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




回答4:


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:

"SET PGPASSWORD=<password>"

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




回答5:


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

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



回答6:


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

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



回答7:


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

hostname:port:database:username:password

read more here



来源:https://stackoverflow.com/questions/11865596/pg-dump-too-many-command-line-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!