我的 Ubuntu 16.04 系统中安装了 postgresql。我正在尝试备份数据库,但它不起作用,
user1@rajeshN ~ $ sudo pg_dump -U postgres teleshop_development1 > pg_backup
[sudo] password for user1:
pg_dump: [archiver (db)] connection to database "teleshop_development1" failed: FATAL: Peer authentication failed for user "postgres"
所以我切换到 postgres,并在那里尝试但我不知道密码
user1@rajeshN ~ $ sudo -i -u postgres
postgres@rajeshN:~$
postgres@rajeshN:~$ sudo pg_dump -U postgres teleshop_development1 > pg_backup
[sudo] password for postgres:
Sorry, try again.
请建议我如何获取密码或备份。提前致谢!
最佳答案
当你已经是用户“postgres”时,不要再使用sudo
。只是
postgres@rajeshN:~$ pg_dump teleshop_development1 > pg_backup
或者您可以在一行中完成所有操作
user1@rajeshN ~ $ sudo -u postgres pg_dump teleshop_development1 > pg_backup
关于postgresql - 从 Postgres 备份数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53540271/