停用 postgres 用户帐户
有没有办法通过 SQL 语句停用 postgres 用户帐户?
我想阻止用户使用他们的数据库,但不删除用户或其数据库。
Is there a way to deactivate a postgres user account via an SQL statement?
I want to prevent a user from using their database, but without deleting the user or their databases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以考虑
ALTER USER person WITH NOLOGIN;
如果您在同一后端有多个数据库并且想要完全阻止用户,这可能是正确的解决方案。锁定帐户:
解锁帐户:
检查帐户是否锁定:
You might also consider
ALTER USER someone WITH NOLOGIN;
which is probably the right solution if you have multiple databases in the same back-end and want to block the user entirely.To lock an account:
To unlock an account:
Check account is locked or not:
查看 REVOKE 命令。
为了让用户连接到数据库,他被授予 CONNECT 权限。
只需撤销此权限,他将无法使用此数据库。
Take a look at the REVOKE command.
In order for a user to connect to a database he has been granted the CONNECT privilege.
Just REVOKE this privilege and he won't be able to use this database.