The authentication type 10 is not supported. Check that you have configured the pg_hba.conf

文章介绍了如何在Docker中的Postgres数据库中创建用户和角色,授予只读权限,以及管理默认权限。同时,针对远程连接错误,提到了修改pg_hba.conf配置文件以允许IP访问,并重新加载配置。
摘要由CSDN通过智能技术生成

--进入容器例如postgres

docker exec -it 容器id bash

--psql命令以某个用户进入postgres数据库

psql -U 用户名称-d 数据库

授权用户只读权限 --创建角色
CREATE role 角色名称;
--创建用户
CREATE USER 用户名 WITH PASSWORD '密码';
--授权select(历史表)
GRANT SELECT ON ALL TABLES IN schema public TO 角色名称;
--设置默认(可以访问新建的表)
alter default privileges in schema public grant select on tables to 角色名称;
--授权角色给用户
GRANT 角色名称 TO 用户名;
--取消角色readaccess包含select的所有权限
revoke all on all tables in schema public from 角色名称;
--取消用户itmario包含select的所有权限
revoke all on all tables in schema public from 用户名;
--删除用户角色
drop role 角色名称;
--删除用户
drop user itmario;
--设置默认授权所有权限表给用户用户名
alter default privileges in schema public grant all privileges on tables to 用户名;
--设置默认授权所有权限序列给用户itmario
alter default privileges in schema public grant all on sequences to 用户名;
--回收/取消默认授权所有权限表给用户itmario
alter default privileges in schema public revoke all privileges on tables from 用户名;
--回收/取消默认授权所有权限序列给用户itmario
alter default privileges in schema public revoke all on sequences from 用户名;

参考资料

PostgreSQL 创建只读用户,并开放特定的表。(实例)_那后生的博客-CSDN博客

远程链接报错信息

The authentication type 10 is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or subnet, and that it is using an authentication scheme supported by the driver.
 

修改pg_hba.conf配置文件当中的ipv4如下

# IPv4 local connections:
#host   all             all             127.0.0.1/32            trust
host    all             all             0.0.0.0/0               trust

The authentication type 10 is not supported - 简书

重新加载生效

select pg_reload_conf();

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值