人防工程建设网站,wordpress如何更新临时域名,建设博客网站步骤,网络服务大厅本站以分享各种运维经验和运维所需要的技能为主 《python零基础入门》#xff1a;python零基础入门学习 《python运维脚本》#xff1a; python运维脚本实践 《shell》#xff1a;shell学习 《terraform》持续更新中#xff1a;terraform_Aws学习零基础入门到最佳实战 《k8… 本站以分享各种运维经验和运维所需要的技能为主 《python零基础入门》python零基础入门学习 《python运维脚本》 python运维脚本实践 《shell》shell学习 《terraform》持续更新中terraform_Aws学习零基础入门到最佳实战 《k8》从问题中去学习k8s 《docker学习》暂未更新 《ceph学习》ceph日常问题解决分享 《日志收集》ELK各种中间件 《运维日常》运维日常 《linux》运维面试100问 《DBA》db的介绍使用mysql、redis、mongodb... mysql用户权限管理
Linux系统mysql数据库用户的作用1.登录系统 2.启动进程 3.文件权限1.登录数据库 2.管理数据库创建用户1.useradd 2.adduser1.grant 2.create user rootlocalhost 3.insert删除用户1.userdel -r1.drop user rootlocalhost 2.delete修改用户1.usermod1.update查看用户1.id 2.passwd1.select user from mysql.user;
1.在MySQL中用户是怎么定义的
#mysql中定义一个用户是用户名主机域#用户名写法用户名如果是字符mysql create user root10.0.0.1;用户名是数字需要加引号mysql create user 12310.0.0.1;#主机域的写法localhost127.0.0.1172.16.1.51db01172.16.1.%172.16.1.5% #172.16.1.50-59172.16.%.%172.%.%.%%10.0.0.0/255.255.255.010.0.0.0/24 #可以设置但是不生效
2.用户的管理
1创建用户
mysql create user rootlocalhost;
mysql grant all on *.* to rootlocalhost identified by 123;
mysql insert ...
2查看用户
mysql select user,host from mysql.user;
3修改用户密码
1.命令行使用mysqladmin修改密码
[rootdb02 ~]# mysqladmin -uroot -p123 password 1234562.update修改用户密码
mysql update mysql.user set passwordPASSWORD(123) where userroot and hostlocalhost;3.修改当前用户密码
mysql set passwordpassword(123456);4.grant修改密码
mysql grant all on *.* to rootlocalhost identified by 123;
mysql flush privileges;
4删除用户
mysql drop user qiudao10.0.0.0/24;
5忘记root用户密码怎么办
1.停止数据库
systemctl stop mysqld2.跳过授权表和网络启动
mysqld_safe --skip-grant-tables --skip-networking 3.登录数据库
mysql4.修改密码
mysql flush privileges;
mysql grant all on *.* to rootlocalhost identified by 123;
mysql flush privileges;5.退出重启数据库
mysqladmin -p123 shutdown
systemctl start mysql
3.权限的管理
1授权命令
grant all on *.* to rootlocalhost identified by 123;
grant all privileges on *.* to rootlocalhost identified by 123;grant #授权命令
all privileges #权限所有权限
on #在...上
*.* #所有库.所有表
to #给
rootlocalhost #用户名主机域
identified #设置密码
by #是
123; #密码
2所有权限
#查看用户权限
mysql show grants for lhd10.0.0.0/255.255.255.0;#回收权限
mysql revoke drop on *.* from lhd10.0.0.0/255.255.255.0;#所有权限
SELECT, INSERT, UPDATE, DELETE, CREATE, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DROP, GRANT
3作用对象
#授权rootlocalhost对所有库所有表拥有所有权限密码是123
grant all on *.* to rootlocalhost identified by 123; #所有库所有表授权
#授权rootlocalhost对wordpress库下所有表拥有所有权限密码是123
grant all on wordpress.* to rootlocalhost identified by 123; #单库授权
#授权rootlocalhost对wordpress库下所有表拥有查看插入修改的权限密码是123最常用
grant select,insert,update on wordpress.* to rootlocalhost identified by 123; #指定权限单库授权
#授权rootlocalhost用户对mysql库下的user表拥有查看插入修改的权限密码是123
grant select,insert,update on mysql.user to rootlocalhost identified by 123; #单表授权
#在企业中单列授权被称为脱敏
grant select(user) on mysql.user.host to rootlocalhost identified by 123; #单列授权
4在企业里权限设定
#开发跟你要一个数据库用户
1.你要操作什么库有没有指定表
2.你要什么用户
3.你从哪台主机连过来
4.密码你有没有要求
5.这个用户你要用多久
6.走流程发邮件
#一般情况给开发的权限
grant select,update,insert on dev.* to dev172.16.1.50 identified by QiuDao123;
#开发你把root用户给我呗
4.权限设置实践
1准备数据库
#创建wordpress数据库
create database wordpress;
#使用wordpress库
use wordpress;
#创建t1、t2表
create table t1 (id int);
create table t2 (id int);#创建blog库
create database blog;
#使用blog库
use blog;
#创建t1表
create table tb1 (id int);
2授权
#授权wordpress10.0.0.5%对于所有库所有表有查看权限密码是123
1.grant select on *.* to wordpress10.0.0.5% identified by 123;#授权wordpress10.0.0.5%对于wordpress下所有表有插入删除修改权限密码是123
2.grant insert,delete,update on wordpress.* to wordpress10.0.0.5% identified by 123;#授权wordpress10.0.0.5%对于wordpress下t1表所有权限密码123
3.grant all on wordpress.t1 to wordpress10.0.0.5% identified by 123;
3提问
#有一个人使用wordpress用户通过10.0.0.51登录数据库请问
1.对于t1表有哪些操作权限所有权限
2.对于t2表有哪些操作权限增、删、改、查
3.对于tb1表有哪些操作权限查
4总结
1.如果不在同一级别授权权限是相加关系
2.但是我们不推荐在多级别定义重复权限。
3.最常用的权限设定方式是单库级别授权即grant select,update,insert on dev.* to dev172.16.1.50 identified by QiuDao123;
4.如果涉及到敏感信息我们使用脱敏即单列授权grant select(user) on mysql.user.host to rootlocalhost identified by 123;
5.查看用户权限show grants for 用户名主机域;