12、等保2.0 Mysql数据库命令

第一部分

select version(); //mysql版本查询 访谈有没有定期扫描,有漏洞是否修复

select user(); //取得当前登录的用户

select * from mysql.user; 查询mysql.user表中的所有内容

SELECT User, Host, Password from mysql.user; // 5.7版本以下查看用户名密码

select User,authentication_string,Host from mysql.user; // 5.7版本以上查看用户名和密码

show variables like ‘validate_password%’; //查看密码复杂度策略

show global variables like “%max_connect%”; //最大登录次数,默认100不生效,需访谈有无第三方

show global variables like ‘%timeout%’; //超时自动退出

show variables like ‘%connection_control%’; //看是否有登录超时策略

show variables like ‘have%ssl%’; //远程加密管理

select * from information_schema.user_privileges; //查看用户权限表中的内容

show global variables like ‘%general%’; //查看是否开启审计,默认为off,不符合,建议第三方审计

show variables like ‘%audit%’; //查看日志配置

show master status; //查看日志记录情况

show status like ‘%connect%’;

show variables like ‘%skip_networking%’;

show variables like ‘require_secure_transport’; 检查是否开启了强制SSL通信(语法有误)\c

select database(); 查看当前在哪个数据库中

show databases; 查看有哪些数据库

输入时需要做部分修改的命令

select * from mysql.general_log; 没开启审计为空表(该表记录sql执行记录)

show grants for root@localhost; //查看某用户权限


SHOW VARIABLES LIKE ‘basedir’; 查看mysql安装路径,找配置文件

第二补充部分

检查SSL/TLS配置:

SHOW VARIABLES LIKE ‘have_ssl’;

SHOW VARIABLES LIKE ‘ssl_cipher’;

SHOW VARIABLES LIKE ‘ssl_cert’;

SHOW VARIABLES LIKE ‘ssl_key’;

检查用户名和密码策略:

SELECT user, host FROM mysql.user;

SHOW VARIABLES LIKE ‘validate_password%’;

show variables like ‘validate%’;

登录失败处理功能和超时退出:

登录失败功能需要mysql安装connection_control.dll或者connection_control.so插件才能实现(Windows:connection_control.dll,Linux:connection_control.so)

show variables like ‘%connection_control%’;

或核查my.cnf配置文件或者my.ini配置文件(Windows:my.ini,Linux:my.cnf)。

show variables like ‘%timeout%’;

检查权限和角色授权:

SHOW GRANTS FOR username;

SHOW GRANTS FOR role;

SELECT * FROM mysql.role_edges;

检查远程访问权限:

SELECT user, host FROM mysql.user WHERE host NOT LIKE ’localhost’ AND host NOT LIKE ‘127.0.0.1’;

检查日志记录配置:

show global variables like ‘%general%’;

SHOW VARIABLES LIKE ’log_error’;

SHOW VARIABLES LIKE ‘general_log’;

SHOW VARIABLES LIKE ‘general_log_file’;

SHOW VARIABLES LIKE ’log_output’;

SHOW GLOBAL STATUS LIKE ‘Uptime’;

show global variables like ‘%general%’;

检查数据库备份策略:

SHOW VARIABLES LIKE ‘datadir’;

SHOW VARIABLES LIKE ‘innodb_data_home_dir’;

SHOW VARIABLES LIKE ‘innodb_log_group_home_dir’;

SHOW VARIABLES LIKE ‘innodb_backup_home_dir’;

检查安全漏洞和补丁情况:

SELECT VERSION();

SELECT @@version_compile_os;

show variables where variable_name like ‘version’;

show variables where variable_name like ‘%version%’;

检查系统监控和报警配置:

SHOW GLOBAL STATUS LIKE ‘Slow_queries’;

SHOW GLOBAL STATUS LIKE ‘Threads_running’;

SHOW GLOBAL STATUS LIKE ‘Threads_connected’;

SHOW GLOBAL STATUS LIKE ‘Max_used_connections’;