Far*_*zem 5 postgresql cmd postgresql-9.5
我想在命令行中使用 pg_restore 恢复我的数据库 postgres 并且我想将用户的密码直接放在命令中,我试过这个命令但不起作用
pg_restore -h localhost -p 5432 -U postgres -W 123 -d my_db my_backup.backup
Run Code Online (Sandbox Code Playgroud)
但显示以下消息
pg_restore: too many arguments on the command line (the first being "-d")
Run Code Online (Sandbox Code Playgroud)
将密码设置为环境变量:set "PGPASSWORD=123"
您也可以通过这种方式设置其他参数:https : //www.postgresql.org/docs/current/static/libpq-envars.html
-W 是强制密码提示,而不是直接提供密码,这就是为什么它说参数太多。
把它们放在一起:
set "PGPASSWORD=123"
pg_restore -h localhost -p 5432 -U postgres -d my_db my_backup.backup
Run Code Online (Sandbox Code Playgroud)
更新:谢谢@aschipfl,我最初的引用不正确 set
| 归档时间: |
|
| 查看次数: |
5473 次 |
| 最近记录: |