日期:2014-05-17  浏览次数:21023 次

批处理下如何自动输入密码?
windows XP下安装了postgresql数据库后,想做个双硬盘的备份,但是调用以下批处理的命令时,会要求输入用户postgres的密码,如何在批处理文件中自动实现输入密码?
pg_dump -h localhost -p 5432 -U postgres db_storelib > "d:\storelib_20111105.backup"

------解决方案--------------------
试试下面的格式行不行

echo 密码|pg_dump -h localhost -p 5432 -U postgres db_storelib > "d:\storelib_20111105.backup"
------解决方案--------------------
-w
--no-password
Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.