客户端默认显示历史登录信息
简介
为了进一步确保用户安全使用平凯数据库,用户通过 MySQL client 登录平凯数据库时,会在客户端显示最近一次成功登录及最近一次失败登录信息,方便用户判断是否存在暴力破解。
开启客户端默认显示历史登录信息
开启客户端默认显示历史登录信息配置
显示上次登录信息依赖用户历史登录记录查询,用户历史登录记录查询功能开启后,同时开启客户端默认显示历史登录信息,用户登录平凯数据库才能显示历史登录信息。
开启用户历史登录记录查询
set global tidb_enable_login_history = ON;
开启客户端默认显示历史登录信息配置
set global tidb_enable_last_login_info = ON;
查询是否默认显示历史登录信息
通过查询系统变量,可以确认集群是否开启默认显示历史登录信息,查询方式如下:
MySQL [(none)]> show variables like '%tidb_enable_last_login_info%';
+-----------------------------+-------+
| Variable_name | Value |
+-----------------------------+-------+
| tidb_enable_last_login_info | ON |
+-----------------------------+-------+
1 row in set (0.00 sec)
默认显示历史登录信息样例
$ mysql -uroot -P4000 -h127.0.0.1
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 2097160
Server version: 8.0.11-TiDB-v7.1.8-5.2-41-g774c4b3076 TiDB Server (Apache License 2.0) Enterprise Edition, MySQL 8.0 compatible
login history:
last fail login:login_time:2024-05-30 10:03:08.426779 login_user:root@% client_host: 127.0.0.1
last success login:login_time:2024-05-30 10:02:55.175246 login_user:root@% client_host: 127.0.0.1
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>