ilovepython

一、mysql查询与权限

(二)授权

用户管理:

  • 设置用户密码

前期准备工作:
停止服务

将配置文件当中的skip-grant-tables删除掉
在这里插入图片描述
重启服务:
在这里插入图片描述

执行修改命令
在这里插入图片描述
查看用户状态(如果数据过多,用\G可以规范布局)

SELECT user,host, authentication_string FROM user;

在这里插入图片描述
常规登录:
在这里插入图片描述
简单登录:
在这里插入图片描述

**权限设置:**

用户:使用系统的账号,身份
权限:可被允许操作的范围
组:针对用户权限的集合
授权
用户:
创建用户

Create user abc@localhost;创建abc用户,允许本地的登陆
create user abc@\'%.%.%.%\'; 创建abc用户,允许所有用户登陆

创建用户并设置密码:

create user abc@localhost identified by \'123\';

删除用户

drop user abc@”%.%.%.%”

授权:

  • 常规权限
    ----select 查询
    ---- insert 插入
    ----update 更新
    -----delete 删除
    -----create 创建

GRANT command ON databases.table TO user@host;

对指定用户的指定IP登陆授权操作指定的数据库的表相应权限

授权abc本地登陆拥有school库student表的查询权限

grant select on school.student to abc@\'localhost\';

授权abc192.168.10.10登陆拥有school库student表的id字段的查询权限

grant select(id) on school.student to abc@\'192.168.10.10\';

授权abc192.168.10.10登陆拥有school库student表的查询和插入权限

grant select,insert on school.student to abc@\'192.168.10.10\';

授权abc192.168.10.10登陆拥有school库所有表的查询和插入权限

grant select,insert on school.* to abc@\'192.168.10.10\';

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
猜你喜欢
  • 2021-10-07
  • 2021-12-20
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案