Home  >  Article  >  Database  >  mysql权限学习_MySQL

mysql权限学习_MySQL

WBOY
WBOYOriginal
2016-06-01 13:44:46773browse

bitsCN.com

 

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 mysql.* 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;

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn