OpenGauss是一款全面友好开放,携手伙伴共同打造的企业级开源关系型数据库;OpenGauss3.0.0默认使用sha256加密认证,所以只支持md5加密认证的Navicat默认不受支持,需要配置数据库的密码加密方式为md5才可以使用Navicat连接。
环境准备
Navicat版本:15
OpenGauss版本:3.0.0
CentOS版本:7.9.2009
配置步骤
请在数据库关闭的情况下进行配置操作
1.关闭防火墙及SElinux
#使用root用户执行
[root@opengauss ~]# systemctl status firewalld
[root@opengauss ~]# systemctl stop firewalld
[root@opengauss ~]# systemctl disable firewalld
[root@opengauss ~]# setenforce 0
[root@opengauss ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
2.切换到omm管理用户
[root@opengauss ~]# su - omm #切换到OpenGauss管理用户omm
3.配置pg_hba.conf
#OpenGauss默认数据目录/opt/software/openGauss/data/single_node/
[omm@opengauss ~]$ vim /opt/software/openGauss/data/single_node/pg_hba.conf
# ... ...
# 配置样例
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust #该项配置成trust,本地命令行客户端登录将免密;如果你配置成md5,无法本地无法登录数据库,请将此项设置成trust后,再登录客户端重置密码
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5 #使任何地址均可使用md5加密认证方式连接到OpenGauss
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication omm md5
#host replication omm 127.0.0.1/32 md5
#host replication omm ::1/128 md5
4.配置postgresql.conf
[omm@opengauss ~]$ vim /opt/software/openGauss/data/single_node/postgresql.conf
# ... ...
# 修改以下所列参数
listen_addresses = '*' # what IP address(es) to listen on;
local_bind_address = '0.0.0.0'
password_encryption_type = 0 #Password storage type, 0 is md5 for PG, 1 is sha256 + md5, 2 is sha256 only
5.启动数据库
[omm@opengauss ~]$ /opt/software/openGauss/bin/gs_ctl start -D /opt/software/openGauss/data/single_node -Z single_node
6.创建用于Navicat连接的用户
#因为系统安全限制,初始用户omm不允许远程连接,所以需要额外创建一个新用户用于远程连接
#因为刚才将本地登录设置为trust(也就是免密登录本地命令行客户端)所以这里可以直接使用gsql登录而不需要密码
[omm@opengauss ~]$ gsql -d postgres
openGauss=# CREATE USER test PASSWORD 'test@666';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
#因为已经将数据库的加密方式配置为md5,所以创建用户时,将直接为该用户的密码使用md5加密
7.赋予Navicat连接用户权限
openGauss=# ALTER ROLE cxk SYSADMIN;
ALTER ROLE
#因为是测试环境,所以赋予SYSADMIN权限
测试Navicat连接OpenGauss
测试使用PIGOSS BSM监控系统自动发现OpenGauss资源