Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
477 views
in Technique[技术] by (71.8m points)

PostgreSQL 新增的用户 怎么像mysql那样只能连接指定的数据库不能进其他数据库。

sql:

create role test with login password 'test' noinherit;
create database test owner test;

pg_hba:

host all all 0.0.0.0/0 md5;
local all all md5;

登录:

psql -U test -d test

test#= c 其他数据库
其他数据库#= ??

怎么像mysql那样主动授权后才能进不授权不能进。这个好像是默认都能进。

pgsql好像刚好反过来,主动取消授权的不能进,其他都能进。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

因为默认每个用户都在 PUBLIC 里,你需要把它的 VIEW ANY DATABASE 权限关掉就可以了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...