I want to restore my database postgres using pg_restore in command line and i want to put the password of user directly in the command, I tried this command but doesn't work
pg_restore -h localhost -p 5432 -U postgres -W 123 -d my_db my_backup.backup
but the following message is displayed
pg_restore: too many arguments on the command line (the first being "-d")
Set the password as an environment variable: set "PGPASSWORD=123"
You can set other arguments this way as well: https://www.postgresql.org/docs/current/static/libpq-envars.html
-W
is to force a password prompt, not to supply a password directly, thats why it says there are too many arguments.
Putting it all together:
set "PGPASSWORD=123"
pg_restore -h localhost -p 5432 -U postgres -d my_db my_backup.backup
Update: Thanks @aschipfl, I initially had incorrect quoting on set
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With