首页 > 解决方案 > pg_dump 和超级用户

问题描述

如果我是系统用户 postgres,PostgreSQL 允许我以超级用户身份连接:

[T] jeff@nantes-5p:~ $ sudo -u postgres psql
psql (10.15 (Ubuntu 10.15-0ubuntu0.18.04.1))
Type "help" for help.

postgres=# 

结果,我巧妙地没有创建超级用户。但似乎 pg_dump 不提供此快捷方式:

130,[T] jeff@nantes-5p:~ $ sudo -u postgres pg_dump -h localhost -p 5432 -U postgres -w
pg_dump: [archiver (db)] connection to database "postgres" failed: fe_sendauth: no password supplied
1,[T] jeff@nantes-5p:~ $ sudo -u postgres pg_dump -h localhost -p 5432 -w
pg_dump: [archiver (db)] connection to database "postgres" failed: fe_sendauth: no password supplied
1,[T] jeff@nantes-5p:~ $ sudo -u postgres pg_dump -h localhost -w
pg_dump: [archiver (db)] connection to database "postgres" failed: fe_sendauth: no password supplied
1,[T] jeff@nantes-5p:~ $ 

我错过了什么?创建超级用户只需要 root 但转储表需要 root 可以做的事情,这似乎不一致,而且有点愚蠢。

标签: postgresqlpostgresql-10

解决方案


推荐阅读