GBase 8a集群数据库用户密码过期功能

GBase 8a集群数据库用户密码过期功能password expire

单独设置一段时间

gbase> alter user testdb password expire interval 100 day;
Query OK, 0 rows affected (Elapsed: 00:00:00.01)

设置立即过期

gbase> alter user masked password expire;
Query OK, 0 rows affected (Elapsed: 00:00:00.21)
gbase> ^CAborted

查看密码过期时间

null等于never不会过期。

gbase> select trim(user),password_life_time from gbase.user_check;
+------------+--------------------+
| trim(user) | password_life_time |
+------------+--------------------+
| root       |               NULL |
| gbase      |               NULL |
| uservc1    |               NULL |
| testdb     |                100 |
+------------+--------------------+
4 rows in set (Elapsed: 00:00:00.00)

测试过期用户

-- 测试过期用户
[root@gbase86_1 zxq]# gccli -umasked -pmasked
GBase client 8.6.2.38-R1.105911. Copyright (c) 2004-2018, GBase. All Rights Reserved.

-- 运行一般SQL报错
gbase> use testdb;
ERROR 1834 (HY000): You must reset your password using ALTER USER statement before executing this statement.

更改新密码后可继续使用

-- 更改密码SQL可以运行
gbase> set password=password('masked');
Query OK, 0 rows affected (Elapsed: 00:00:00.05)

-- 更改后,当前连接不生效,需要重新登陆(用了连接池的话,老的连接每个都要关闭重连)
gbase> use testdb;
ERROR 1834 (HY000): You must reset your password using ALTER USER statement before executing this statement.
gbase> flush privileges;
ERROR 1834 (HY000): You must reset your password using ALTER USER statement before executing this statement.
gbase> ^CAborted

-- 重新登陆
[root@gbase86_1 zxq]# gccli -umasked -pmasked
GBase client 8.6.2.38-R1.105911. Copyright (c) 2004-2018, GBase. All Rights Reserved.

-- 执行SQL成功
gbase> use testdb;
Query OK, 0 rows affected (Elapsed: 00:00:00.08)

JDBC修改密码

JDBC修改需要用新版的jar修改密码
gbase-connector-java-8.3.81.53-build55.4.1-bin
如下方法修改
import com.gbase.jdbc.util.PasswordChangeUtil;

String url = "jdbc:gbase://192.168.163.101:5258/testdb?user=testdb&password=testdb";
// changePasswordNormal(url, "testdb", "testdb", "testdb2");
PasswordChangeUtil.changePassword(url, "testdb2");


发表评论

您的电子邮箱地址不会被公开。