Home > Database > Mysql Tutorial > mysql 用户权限管理 例子

mysql 用户权限管理 例子

WBOY
Release: 2016-06-07 15:24:58
Original
1117 people have browsed it

USE mysql; SELECT user FROM user; SELECT host,user,password FROM user; CREATE USER testuser IDENTIFIED BY '111111'; RENAME USER testuser TO zhang; DROP USER zhang; SHOW GRANTS FOR zhang; 没有任何权限; GRANT SELECT ON ajax.* TO zhang; #授权

USE mysql;

SELECT user FROM user;

SELECT host,user,password FROM user;

CREATE USER  testuser  IDENTIFIED BY '111111';

RENAME USER  testuser  TO zhang;

DROP USER zhang;

SHOW GRANTS FOR zhang;

mysql 用户权限管理  例子

没有任何权限;


GRANT SELECT ON ajax.* TO zhang; #授权用户zhang,在ajax数据库中的表有SELECT权限

mysql 用户权限管理  例子


撤销权限操作:

REVOKE SELECT ON ajax.* FROM zhang;#撤销用户zhang,在ajax数据库中的表有SELECT权限

撤销的时候,权限必须存在,否则会出错;


GRANT 和 REVOKE 可在几个层次上控制访问权限:

1)整个服务器,使用GRANT ALL 和 REVOKE ALL;

2)整个数据库,使用 ON database.*;

3)特定的表,使用ON database.tablename;

4)特定的列;

50特定的存储过程;


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

show processlist;#显示所有活动进程,线程Id和执行时间

show variables;#显示当前设置

show status;#显示当前状态


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template