mariadb数据库的用户和权限,mariadb数据库权限
实验--用户
use mysql
show tables;
desc uesr; #存放mysql的用户
select host,user,password from user;
create user qin@'%' identified by '123465';
create user qin@'192.168.100.2' identified by '123465';
create user qin@'192.168.100.0/255.255.255.0' identified by '123465';
#创建远程连接用户(%在红帽7里只表示所有远程连接的用户)yum istall mariadb 客户端安装这个
mysql -h 192.168.100.1 -u qin -p 远程连接
create user qin@'localhost' identified by '123456'; #创建本地登入用户(企业的本地登入使用的较多)
drop user qin@'%'; #删除用户
show privileges; #查看权限列表
grant select on scott.* to qin@'localhost';
授权 权限 库 表 那个用户
flush privileges; #刷新一下权限表
select * from emp;
drop table emp; #使用 qin@'localhost登入,无权删除
show grants for qin@'localhost'; #查看用户权限
revoke select on scott.* from qin@'localhost'; #收回权限
grant all on *.* to qinbing@'localhost' identified by '123456'; 授权 建用户 设密码一起创建修改密码
第一种:mysqladmin -u root -p password 'redhat'; #修改密码
第二种:update user set password=password('123456') where user='root' and host='localhost';
第三种:set password=password('redhat');
set password for qin@'localhost'=password('redhat'); #第二种和第三种是在mysql库下修改的
实验--破解mysql密码
第一种:
停止mariadb的服务
在/etc/my.cnf 里添加一行skip-grant-tables 跳过权限
重启服务
mysql -u root -p 直接回车 不用输入密码
use mysql
select host,user,password from user;
update user set password=password('123456') where uesr='root' and host='localhost';
删除skip-grant-tables,重启服务,登入即可
第二种方式:
mysql_safe --skip-grant-tables 再打开一个窗口
直接mysql 进入
修改密码就可以了
重启服务即可
实验--安全脚本
mariadb提高安全性有一种安全的脚本(数据库安装完之后,先执行这个)
mysql_secure_installation 然后一路‘y’即可 然后重启服务即可
show databases;
没有test库 远程的root就不能连了
不允许网络连接 :在配置文件添加一行 skip-networking=1 加一行这个,就不允许远程连接mysql数据库了
netstart -antulp | grep mysql
mysql workbench