mysql-- rights management - Authorization to recover permission to see the authorization

Preparation, create a new user:

the Create  the User  ' SWW ' @ ' localhost ' IDENTIFIED by  ' 123456 ' ;       / * Create a user * / 

the SELECT  *  from  the User ; 

MySQL - H localhost - P 3306  - U SWW - p123456        / * DOS window to sign in to view * /

 

 

 

 

 

========================================================================================

 

Use the grant statement to create a new user and authorization. When you create a user, it can authorize its users. But you must have permission to grant.

 

Syntax: 

 

                  grant   priv_type  [ colunm_list ] on  database.table

                  to   user   [ identified  by  [ PASSWORD ] 'password' ] 

                  [, user  [ identified  by  [ PASSWORD ] 'password' ]……

                  [ with with_option [ with_option ]…… ]

 

priv_type:表示权限类型;

colunm_list:表示权限作用于哪些列上,没有该参数时,表示作用于整个表上;

database.table:表示新用户的权限范围,即只能在指定的数据库和表上使用自己的权限;

user:表示新建用户的账户,user由用户名(user)和主机名(host)构成;

identified  by:关键字用来设置用户的密码;

password:表示用户的密码;如果密码是一个普通的字符串,就不需要用PASSWORD关键字。

 

with后面带有一个或者多个with_option参数,这个参数有5个选项:

 

grant option:被授权的用户,可以将这些权限赋予给别的用户;

max_queries_per_hour count:设置每小时允许执行的count次查询;

max_updates_per_hour count:设置每小时允许执行的count次更新;

max_connections_per_hour count:设置每小时可以建立count连接;

max_user_connections count:设置单个用户可以同时具有的count连接数;

 

---------------------------------------------------------------------------------------------------------------------------------

执行授权语句:

grant select,update on *.* to 'sww'@'localhost' identified by '123456' with grant option;

 

 

 

查询授权信息:

show grants for 'sww'@'localhost';

 

 

 

 

或者:

select * from mysql.user;

 

 

 

 

 

 

收回部分权限:

revoke select on *.* from 'sww'@'localhost';   /*收回select权限*/

 

 

 

 

 

 

 

 

收回全部权限:

revoke all PRIVILEGES,GRANT option from 'sww'@'localhost';   /*收回全部权限*/

 

 

 

 

 

 

 

 

===========================================================

 

查看授权信息:

show grants for 'sww'@'localhost';

select * from mysql.user;

 

方法一:   select * from mysql.user;

 

方法二:   show grants for 'username'@'hostname';

 

username:表示用户名;

 

hostname:表示主机名或者主机IP;

 

 

 

 

======================================================

 

收回权限:

revoke select on *.* from 'sww'@'localhost';   /*收回select权限*/

revoke all PRIVILEGES,GRANT option from 'sww'@'localhost';   /*收回全部权限*/

 

语法格式: 

 

                  revoke  priv_type  [ colunm_list ]……

                  on  database.table

                  from user [ ,user ]……

========================================================

Guess you like

Origin www.cnblogs.com/xiaobaibailongma/p/12099999.html