用户权限管理

来源:互联网 发布:python ffmpeg 库安装 编辑:程序博客网 时间:2024/06/15 19:12
一,权限范围:
1,全局
grant all on *.* to 'qn'@'%'
2,数据库
grant all on test.* to 'qn'@'%'
3,表
grant all on test.q to 'qn'@'%'
4,列
grant select(q) on test.q to 'qn'@'%'

二,比较特别权限type :
all : 指所有权限
USAGE : 没权限匿名

三,特殊库Test:
By default, the mysql.db table contains rows that permit access by any user to the test database and other databases with names that start with test_. (These rows have an empty User column value, which for access-checking purposes matches any user name.) This means that such databases can be used even by accounts that otherwise possess no privileges. If you want to remove any-user access to test databases, do so as follows:
默认,mysql.db记录了允许对test库或者以test_开头库的访问的用户。有写记录USER列值是空,匹配任何用户作为访问检查的目的。这意味着这库能被用户使用,没有权限的。如果你想移除任何用户对test库的访问。做如下的

shell> mysql -u root -p
Enter password: (enter root password here)
mysql> DELETE FROM mysql.db WHERE Db LIKE 'test%';
mysql> FLUSH PRIVILEGES;

FLUSH语句促使服务重读grant表。否则,权限更改保留未被服务器通知,除非你重启
更改之后,只有有全局数据库权限或明确授权的用户才能访问test库

所以不要用test库做权限的测试

原创粉丝点击