pg_dump: too many command line arguments

45,853

Solution 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

Solution 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.

Solution 3

pg_dump and pg_restore need to ask password on commandline, 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.

Solution 4

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

Solution 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
Share:
45,853
Bhargav Gor
Author by

Bhargav Gor

Updated on July 09, 2022

Comments

  • Bhargav Gor
    Bhargav Gor almost 2 years

    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

  • Daniel Vérité
    Daniel Vérité almost 12 years
    @BhargavGor: omit -W admin, not just -W
  • i0x539
    i0x539 over 6 years
    This was so tech. It saved me from writing from a terrible me expect/spawn bash script. Thank you.
  • mangonights
    mangonights about 6 years
    dude, i'd fking kiss if you were here! lol. watch out for TextEdit auto-correct
  • wmassingham
    wmassingham almost 5 years
    Stupid problems... I had -jobs instead of --jobs.
  • VSO
    VSO over 4 years
    This helped me.
  • juckele
    juckele over 3 years
    This should be the accepted answer. The other answers are simply solving typos.
  • Nirmal Seneviratne
    Nirmal Seneviratne about 2 years
    This worked, but needed single quotation for "mypass".