温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

mysql权限操作的示例分析

发布时间:2022-01-14 16:52:05 来源:亿速云 阅读:144 作者:小新 栏目:数据库

这篇文章给大家分享的是有关mysql权限操作的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

1、创建新用户:

create user mark@localhost identified by '123456';

2、删除用户:

drop user mark@localhost;

3、修改用户名:

rename user mark@localhost to mark1@localhost;

4、修改用户密码:

set password for mark@localhost = password('111111');

5、授予权限:

(1)授予表权限:select,insert,delete,update,references,create,alter,index,drop,all或者all privileges.

use mysql;

grant select on user to mark@localhost;

(2)授予权 限:select,insert,delete,update,references,create,alter,index,drop,create temporary tables,create view,show view,create routine,alter routine,execute routine,lock tables,all或者all privileges.

grant select on .* to mark@localhost;

(3)授予用户权限:create user,show databases

grant create user on *.* to mark@localhost;

grant create,alter,drop on *.* to mark@localhost;

6、权限的转移和限制

(1)grant语句最后加with grant option,表示该用户有把自己的权限授予其它用户的权利,而不管其它用户是否有该权限。

grant select on mysql.user to mark@localhost with grant option;

重新用mark登录数据库后,mark可以授予别的用户相同的权限。

(2)with子句也可以对一个用户授予实用限制。

max_queries_per_hour 1   每小时查询数据库次数为1。

max_connections_per_hour 1  每小时可以连接数据库次数。

max_updates_per_hour 1     每小时可以修改数据库次数

max_user_connections 1      同时连接mysql的最大用户数。

如:

grant select on mysql.user to mark@localhost with max_queries_per_hour 1;

7、回收权限。

revoke select on mysql.user from mark@localhost;

感谢各位的阅读!关于“mysql权限操作的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI