1、实验目的
- 验证Mysql创建用户
- 验证Grant授权的作用
- 配置数据库审计,实现对Mysql进行审计
- 验证Mysql创建用户
2、定义用户及授权
//使用root登录Mysql
//创建新用户guest@‘%’,密码123456
CREATE USER 'guest'@'%' IDENTIFIED BY '123456';
select host,user,authentication_string from mysql.user; //查询
//将Users表的查询权限、插入、删除授予该用户
grant select,insert,delete on users to guest;
flush privileges; //刷新
//查询该用户权限是否符合要求
show grants for guest;
3、配置审计功能
方法:init-connect+binlog
(1)第一步 创建审计数据库
//创建审计数据库auditlog;
mysql> create database auditlog
//创建审计日志表
mysql> create table audit(
-> id int not null auto_increment,
-> thread_id int not null,
-> login_time timestamp,
-> localname varchar(50) default null,
-> matchname varchar(50) default null,
-> primary key (id)
-> );
(2)第二步 授权
先查询一下所有user
mysql> SELECT HOST,USER,AUTHENTICATION_STRING FROM mysql.user;
+-----------+------------------+------------------------------------------------------------------------+
| HOST | USER | AUTHENTICATION_STRING |
+-----------+------------------+------------------------------------------------------------------------+
| % | guest | $A$005$h\@Wau9Cky ><zAkGi2ytVpjGFE8jY6PQL1XL2LHIgKI94Mt8bJw5pq9 |
| localhost | mysql.infoschema | $A$0