原文链接:www.gbase.cn/community/p…
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。
本文将详细介绍如何在 GBase 8s 中创建普通用户,并展示如何为这些用户赋权以及如何使用这些用户连接数据库。通过本文你将能够顺利地完成用户创建、赋权和连接数据库的全过程。
探讨Gbase8S创建普通用户方法,直接执行
create user tmp_u001 with password 'GBase123';
可以吗?
> create user tmp_u001 with password 'GBase123';
26707: User (tmp_u001) cannot be created because the user is not mapped to any properties.
Error in line 1
Near character position 44
>
显然直接创建不可以?
那需要怎么办呢?
下面介绍数据库普通用户的创建方法和使用。
1.首先创建操作系统用户,如useraaa1
useradd useraaa1
2.配置allowed.surrogates
在操作系统路径/etc/gbasedbt(如没有,使用root用户创建)下创建allowed.surrogates配置文件,并执行
echo "USERS:useraaa1" >> /etc/gbasedbt/allowed.surrogates
注意新建的allowed.surrogates需要修改属组
chown root:gbasedbt /etc/gbasedbt/allowed.surrogates
3.开启USERMAPPING
执行数据库命令
onmode -wf USERMAPPING=ADMIN
onstat -g cfg | grep USERMAPPING
4.加载surrogates到缓存
onmode -cache surrogates
5.在sysuser库中创建系统默认用户
database sysuser;
create default user with properties user useraaa1;
6.到此就可以创建普通用户了,创建普通用户,可以接着上面操作,在sysuser库中接着执行,也可以重新开一个session执行。创建系统默认用户后,何处都可以创建普通用户!
dbaccess - -
create user tmp_u001 with password 'GBase123';
--或按下面方式创建,显示指定属性
create user 'tmp_u002' with password '123456' properties user 'useraaa1';
7.给普通用户赋权
创建普通用户后,需要给该用户进行赋权,否则不能连接
dbaccess - -
Your evaluation license will expire on 2025-08-21 00:00:00
> connect to 'testdb@ol_gbasedbt1210_20240821112509' user 'tmp_u001';
ENTER PASSWORD:
387: No connect permission.
111: ISAM error: no record found.
Error in line 1
Near character position 1
>
假如已存在root用户创建的库testdb,root用户执行如下语句
database testdb;
grant connect to tmp_u001;
8.使用普通用户tmp_u001访问数据库,按提示输入密码
> !echo $GBASEDBTSERVER
ol_gbasedbt1210_20240821112509
> connect to 'testdb@ol_gbasedbt1210_20240821112509' user 'tmp_u001';
ENTER PASSWORD:
Connected.
> info tables;
Table name
t1
> select * from t1;
id
1
1 row(s) retrieved.
>
至此,为创建普通用户的全过程,及赋权,连接使用!
如果在用户管理过程中遇到任何问题,欢迎随时在社区中提问,我们在这里为您提供支持!
原文链接:www.gbase.cn/community/p…
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。