MySQL 安全性与访问控制

别来无恙 提交于 2019-11-28 11:15:29

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;

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!