所以我 Build 了一个名为'paperwork'的用户,其中包含一个同名的数据库
postgres=# create role paperwork;
postgres=# create database paperwork;
postgres=# grant all privileges on database paperwork to paperwork;
postgres=# ALTER ROLE paperwork WITH LOGIN;
postgres=# ALTER ROLE paperwork WITH PASSWORD 'paperwork';
但它仍然允许我在没有密码的情况下以书面形式登录
[###@EMOO modules]$ psql --username=paperwork --host=localhost
psql (9.6.3)
Type "help" for help.
paperwork=> \q
当我强制它使用密码时,它接受任何密码,包括空白密码:
[###@EMOO modules]$ psql --username=paperwork --host=localhost --password
Password for user paperwork:
psql (9.6.3)
Type "help" for help.
当我打开pgadmin3并点击“文书工作”用户时,似乎有一个加密密码 .
-- Role: paperwork
-- DROP ROLE paperwork;
CREATE ROLE paperwork LOGIN
ENCRYPTED PASSWORD 'md585ff97314dbeb9953b989fd363a8e96f'
NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;
另外,当我打开pgadmin3时它会询问我的postgres密码,但是再次接受postgres密码的任何内容 . (我记得在安装postgres时设置了postgres密码)如何制作,以便您需要正确的密码才能登录?或者这里有一些我完全错过的背景? . . . 像密码只需要远程登录或一些古怪 . 谢谢 .
编辑:我没有/usr/share/postgresql/pg_hba.conf(编辑:实际上我做了我只是找不到它,因为我没有在“locate”命令上使用sudo)我创建了一个示例文件:/usr/share/postgresql/pg_hba.conf.sample
从这里得到这个想法:http://blog.mattsch.com/2012/05/19/postgresql-accepts-any-or-no-password-when-connecting/我试过让它有md5身份验证,但我仍然有同样的问题 . 我尝试的是下面的文件/usr/share/postgresql/pg_hba.conf
@authcomment@
# TYPE DATABASE USER ADDRESS METHOD
@remove-line-for-nolocal@# "local" is for Unix domain socket connections only
@remove-line-for-nolocal@local all all @authmethodlocal@
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
@remove-line-for-nolocal@#local replication @default_username@ @authmethodlocal@
#host replication @default_username@ 127.0.0.1/32 @authmethodhost@
#host replication @default_username@ ::1/128 @authmethodhost@
我然后重新启动postgresql但仍然有同样的问题 .
编辑:谢谢Abelisto . "show config_file"命令(用pgsql登录后)让我走上正轨 . 它没有't occure to me that 1414449 run from my linux user'命令行没有权限在postgres目录中找到实际的配置文件:/ var / lib / postgres / data /用户"paperwork"现在在/ var中将"trust"更改为"md5"后被错误的密码拒绝/lib/postgres/data/pg_hba.conf在这些行上做到:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
可能标记解决了一点只是想测试一些事情 .
1 回答
TLDR我原来的帖子:
1确保您已将postgres密码设置为您知道的密码:
2找到你的pg_hba.conf
3在pg_hba.conf中将“trust”替换为“md5”
4重新启动postgresql:
5登录为postgres并更改您需要的任何用户密码,如果用户没有提供正确的密码,他们现在将被拒绝