MySQL 安全性与访问控制

1、用户账号管理

//对密码进行明文加密设置

->select password(456);
//能够得到对应的散列值

->create user 'zhangsan'@'localhost' identified by'123',
->'lisi'@'localhost' identified by password
->'*531E182E272080AB0740FE2F2D689DBE0156E04';

//创建了两个账号,一个zhangsan密码为123,一个lisi,密码为456


->drop user zhangshan@localhost;
//删除张三的账号

->rename user 'lisi'@'localhost' to 'wangwu
 
 

 

2、grant权限

实例:授予用户zhangsan在数据库mysql_test的表customers上拥有对列cust_id和列cust_name的select权限

->grant select(cust_id,cust_name)
->on mysql_test.customers
->to'zhangsan'@'localhost';

实例:授予当前系统中一个不存在的用户liming和用户huang,要求创建这两个用户,并设置对应的系统 登录口令,同时授予他们在数据库mysql_test的表customers上拥有select和update的权限

->grant select ,update
->on mysql_test.customers
->to'liming'@'localhost' identified by '123',
->'huang'@'localhost' identified by '789';

实例:授予系统中已存在的wangwu可以在数据库mysql_test中执行所有数据库操作的权限

->grant all
->on mysql_test.*
->to'wangwu'@'localhost';

实例:授予系统中已存在wnagwu拥有创建用户的权限


->grant create user
->on *.*
->to 'wangwu'@'localhost';


实例:授予系统中已存在wnagwu拥有创建用户的权限,授予给其他用户


->grant create user
->on *.*
->to 'wangwu'@'localhost'
->with grant option;

 

转载于:https://www.cnblogs.com/cheneyboon/p/11406319.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值