PostgreSQL中,能够经过如下几方面进行限制用户链接:sql
一、pg_hba.conf中配置具体的登陆用户,此配置能够限制超级用户登陆数据库
二、角色属性“connection limit”(定义该角色能够使用的链接数),但该属性对超级用户不生效post
三、max_connection资源参数(最大链接数,含超级用户链接数)postgresql
在postgresql.conf配置文件中,还有一个superuser_reserved_connections参数,对该参数说明以下:资源
一、该参数定义的是max_connections中,应为超级用户保留superuser_reserved_connections个链接,即在PostgreSQL中,超级用户的链接数为 [ superuser_reserved_connections , max_connections ];而普通用户的最大链接数为 max_connections - superuser_reserved_connections 个it
二、PostgreSQL只会去判断 “剩余链接数”应大于“superuser_reserved_connections”,不然普通用户没法访问数据库,而不会去判断已有的connection中是否存在了属于superuser/no-replication superuser的connectionio