本例中的 IP 限制为所有 IP 都可以连接,是以设置为 “*”,mysql 数据库中是经由过程 user 表的 host 字段来进行控制,host 可所以以下类型的赋值。
- Host 值可所以主机名或IP号,或 “localhost” 指出本地主机。
- 可以在 Host 列值应用通配符字符 “%” 和 “_”
- Host 值 “%” 匹配任何主机名,空 Host 值等价于 “%”,它们的含义与 like 操作符的模式匹配操作雷同。
留意: mysql 数据库的 user 表中 host 的值为 “*” 或者空,表示所有外部 IP 都可以连接,然则不包含本地办事器 localhost,是以,如不雅要包含本地办事器,必须零丁为 localhost 付与权限。
如不雅是更改本身的暗码,可以省略 for 语句
(5) 授予 super、process、file 权限给用户 zj3@%
- MySQL [mysql]> grant super,process,file on *.* to 'zj3'@'%';
- Query OK, 0 rows affected, 1 warning (0.00 sec)
因为这几个权限都是属于治理权限,是以不克不及够指定某个数据库,on 后面必须跟 “.”,下面语法将提示缺点
- MySQL [mysql]> grant super,process,file on t2.* to 'zj3'@'%';
- ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
(6) 只授予登录权限给 zj4@localhost
- MySQL [mysql]> grant usage on *.* to 'zj4'@'localhost';
- Query OK, 0 rows affected, 2 warnings (0.01 sec)
- MySQL [mysql]> exit
- Bye
- zj@bogon:~$ mysql -uzj4 -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 78
- Server version: 5.7.18-log Source distribution
- Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h'
推荐阅读
2017年架构师最重要的48个小时 | 8折倒计时 自负年夜2015年我国大年夜力开展“宽带中国”专项行动后>>>详细阅读
本文标题:带您深入了解MySQL的权限管理
地址:http://www.17bianji.com/lsqh/38307.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示