简体   繁体   English

还原备份时,pg_restore 连接到数据库失败错误

[英]pg_restore connection to database failed error while restoring backup

I have a backup file in tar format and there is no problem while getting this backup.我有一个tar格式的备份文件,并且在获取此备份时没有问题。 However, when trying to restore this backup using the following script, I encountered "pg_restore: error: connection to database "db-dev" failed: FATAL: password authentication failed for user "db-dev-user"" error after entering password.但是,当尝试使用以下脚本恢复此备份时,我在输入密码后遇到了“pg_restore:错误:连接到数据库“db-dev”失败:致命:用户“db-dev-user”的密码验证失败”错误。

pg_restore -v -h 127.0.0.1 -p 5432 -d db-dev -U db-dev-user < C:\dB\db-dev.tar

I am trying to restore this backup to a Docker container where I can easily create an empty database with the same name (db-dev).我正在尝试将此备份还原到 Docker 容器,在该容器中我可以轻松地创建一个具有相同名称(db-dev)的空数据库。 I am also using Windows 10. So, how can I fix the problem?我也在使用 Windows 10。那么,我该如何解决这个问题? May the problem related to Docker?可能与Docker有关的问题?

The -U option must specify an existing user in the target database, and you have to specify the user's password when calling pg_restore . -U选项必须指定目标数据库中的现有用户,并且在调用pg_restore时必须指定用户的密码。

Use a user with the permissions required to create the dumped objects and make sure that the target's pg_hba.conf allows the user database access from your client machine.使用具有创建转储对象所需权限的用户,并确保目标的pg_hba.conf允许用户从您的客户端计算机访问数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM