Reputation: 52
1.when i apply this command in commandprompt it askes me to enter the password and i can perform all the action in database
psql -h localhost -p 5432 -U postgres -f test.sql newdb
2.but when i put this command,it shows me error " 'PGPASSWORD' is not recognized as an internal or external command, operable program or batch file."
PGPASSWORD=root psql -h localhost -p 5432 -U postgres -P root -f test.sql newdb
Upvotes: 2
Views: 3600
Reputation: 101
Put your variables as:
PGPASSWORD=%s pg_dump --host=%s --port=%s --username=%s %s -f %s
Change %s
by your valid text.
Upvotes: -1
Reputation:
Ashwin, The PGPASSWORD is not a command it is a system user/global variable which keeps your password stored for you. So, the "psql" command will not ask for password next time. Use the same command that you used early i.e. below one, to connect to database...
psql -h localhost -p 5432 -U postgres -f test.sql newdb
But, this time all you need to do is, set the global variable.
Windows system:
you can set this variable from Environment variable of system properties.
Linux system:
export PGPASSWORD=yourpassword
or, you can add this export inside the ".bashrc" file.
Upvotes: 2