MySQL 8.0权限认证(下)
mysql> CREATE USER 'francis'@'localhost' IDENTIFIED BY 'frank'
-> WITH MAX_QUERIES_PER_HOUR 20
-> MAX_UPDATES_PER_HOUR 10
-> MAX_CONNECTIONS_PER_HOUR 5
-> MAX_USER_CONNECTIONS 2;
mysql> ALTER USER 'francis'@'localhost' WITH MAX_QUERIES_PER_HOUR 100;
mysql> ALTER USER 'francis'@'localhost' WITH MAX_CONNECTIONS_PER_HOUR 0;
mysql> CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
mysql> ALTER USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
mysql> SET PASSWORD FOR 'jeffrey'@'localhost' = PASSWORD('mypass');
mysql> GRANT USAGE ON *.* TO 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
shell> mysqladmin -u user_name -h host_name password "new_password"
mysql> ALTER USER USER() IDENTIFIED BY 'mypass';
mysql> SET PASSWORD = PASSWORD('mypass');
default_password_lifetime=180 设置180天过期
default_password_lifetime=0 设置密码不过期
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE INTERVAL 90 DAY;
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE NEVER; 密码不过期
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE DEFAULT; 默认过期策略
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE;
mysql> SELECT 1;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> ALTER USER USER() IDENTIFIED BY 'new_password';
Query OK, 0 rows affected (0.01 sec)
mysql> create role app_readonly;
Query OK, 0 rows affected (0.09 sec)
#创建一个role叫app_readonly只读
mysql> create user app1@localhost identified by 'mysql';
Query OK, 0 rows affected (0.01 sec)
#创建一个用户app1
mysql> grant select on *.* to app_readonly;
Query OK, 0 rows affected (0.02 sec)
#给app_readonly这个角色一个select权限
mysql> grant app_readonly to app1@localhost;
Query OK, 0 rows affected (0.10 sec)
#把用户和角色绑定
mysql> show grants for app1@localhost;
+------------------------------------------------+
| Grants for app1@localhost |
+------------------------------------------------+
| GRANT USAGE ON *.* TO `app1`@`localhost` |
| GRANT `app_readonly`@`%` TO `app1`@`localhost` |
+------------------------------------------------+
#查询用户的权限
mysql> show grants for app1@localhost using app_readonly;
+------------------------------------------------+
| Grants for app1@localhost |
+------------------------------------------------+
| GRANT SELECT ON *.* TO `app1`@`localhost` |
| GRANT `app_readonly`@`%` TO `app1`@`localhost` |
+------------------------------------------------+
2 rows in set (0.00 sec)
#查询用户的权限
mysql> create role app_readwrite;
Query OK, 0 rows affected (0.04 sec)
mysql> create user app2@localhost identified by 'mysql';
Query OK, 0 rows affected (0.04 sec)
mysql> grant select,insert,delete,update on *.* to app_readwrite;
Query OK, 0 rows affected (0.10 sec)
mysql> grant app_readwrite to app2@localhost;
Query OK, 0 rows affected (0.07 sec)
mysql> show grants for app2@localhost;
+-------------------------------------------------+
| Grants for app2@localhost |
+-------------------------------------------------+
| GRANT USAGE ON *.* TO `app2`@`localhost` |
| GRANT `app_readwrite`@`%` TO `app2`@`localhost` |
+-------------------------------------------------+
2 rows in set (0.00 sec)
mysql> show grants for app2@localhost using app_readwrite;
+-------------------------------------------------------------------+
| Grants for app2@localhost |
+-------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO `app2`@`localhost` |
| GRANT `app_readwrite`@`%` TO `app2`@`localhost` |
+-------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> revoke app_readonly from app1@localhost;
Query OK, 0 rows affected (0.10 sec)
#解除绑定关系
mysql> show grants for app1@localhost using app_readonly;
ERROR 3530 (HY000): `app_readonly`@`%` is not granted to `app1`@`localhost`
mysql> show grants for app1@localhost;
+------------------------------------------+
| Grants for app1@localhost |
+------------------------------------------+
| GRANT USAGE ON *.* TO `app1`@`localhost` |
+------------------------------------------+
MySQL 8.0权限认证(下)的更多相关文章
- MySQL 8.0权限认证(上)
MySQL 8.0授权认证 一.系统权限表 user 存放用户账户信息以及全局级别(所有数据库)权限,决定了来自哪些主机的哪些用户可以访问数据库实例,如果有全局权限则意味着对所有数据库都有此权 ...
- (0)linux下的Mysql安装与基本使用(编译安装)
一.大致操作步骤 环境介绍: OS:center OS6.5 mysql:5.6版本 1.关闭防火墙 查看防火墙状态:service iptables status 这样就意味着没有关闭. 运行以下命 ...
- asp.net权限认证:OWIN实现OAuth 2.0 之客户端模式(Client Credential)
asp.net权限认证系列 asp.net权限认证:Forms认证 asp.net权限认证:HTTP基本认证(http basic) asp.net权限认证:Windows认证 asp.net权限认证 ...
- asp.net权限认证:OWIN实现OAuth 2.0 之密码模式(Resource Owner Password Credential)
asp.net权限认证系列 asp.net权限认证:Forms认证 asp.net权限认证:HTTP基本认证(http basic) asp.net权限认证:Windows认证 asp.net权限认证 ...
- asp.net权限认证:OWIN实现OAuth 2.0 之授权码模式(Authorization Code)
asp.net权限认证系列 asp.net权限认证:Forms认证 asp.net权限认证:HTTP基本认证(http basic) asp.net权限认证:Windows认证 asp.net权限认证 ...
- CentOS 7.x下安装部署MySQL 8.0实施手册
MySQL 8 正式版 8.0.11 已发布,官方表示 MySQL 8 要比 MySQL 5.7 快 2 倍,还带来了大量的改进和更快的性能! 一. Mysql8.0版本相比之前版本的一些特性 1) ...
- windows下安装 mysql 8.0 以上版本以及遇到的问题
Windows 上安装 MySQL Windows 上安装 MySQL 相对来说会较为简单,地那就链接 https://cdn.mysql.com//Downloads/MySQL-8.0/mysql ...
- macOS下MySQL 8.0 安装与配置教程
一.前言 1.本教程主要内容 适用Homebrew安装MySQL MySQL 8.0 基础适用于配置 MySQL shell管理常用语法示例(用户.权限等) MySQL字符编码配置 MySQL远程访问 ...
- linux下mysql开启远程访问权限 防火墙开放3306端口
linux下mysql开启远程访问权限 防火墙开放3306端口 转载 2017-01-21 作者:JAVA-ANDROID 这篇文章主要为大家详细介绍了linux下mysql开启远程访问权限,防 ...
随机推荐
- ORACLE 统计文件后缀SQL
ORACLE 统计文件后缀SQL查询语句 select lower(substr(file_name,instr(file_name, '.', -1),length(file_name))),cou ...
- 前端ie7的兼容问题及解决方案(未完待续)
最近在维护一些老的项目,需要兼容ie7 ,css3就不能用了,这里总结一下碰到的问题及解决方案. 1.盒模型 ie7.8 的盒模型都是 box-sizing为content-box的盒模型,这里在做 ...
- Python PIL Image图片显示系列
1. PIL Image图片显示 在使用PIL函数中的Image方法读取图片时,对于图片的shape,可能有不少宝宝存在疑惑.是什么疑惑了?就是image = Image.open(image_pat ...
- TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
我的项目在mac上运行的很好,结果windows电脑,就一直报这个错误 解决方案: babel增加 @babel/plugin-transform-modules-commonjs 参考文章: htt ...
- C:习题2
C 语言中的数据类型主要有哪些? C 语言为什么要规定对所有用到的变量“先定义后使用”?这样做有什么好处? 1. 编译系统会根据定义为变量分配内存空间,分配空间的大小与数据类型有关 2. 系统可以根据 ...
- 点双连通分量F. Simple Cycles Edges
F. Simple Cycles Edges time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- html浏览器高度和宽度和其他dom获取
1.获取网页可见区域的宽度:document.body.clientWidth ; 2.获取网页可见区域的高度:document.body.clientHeight; 3.获取 网页可见区域宽:doc ...
- ubuntu 基本操作
一 :下载文件操作 wge 下载地址 解压命令: tar
- 如何利用Xpath抓取京东网商品信息
前几小编分别利用Python正则表达式和BeautifulSoup爬取了京东网商品信息,今天小编利用Xpath来为大家演示一下如何实现京东商品信息的精准匹配~~ HTML文件其实就是由一组尖括号构成的 ...
- Flink kuduSink开发
1.继承RichSinkFunction (1)首先在构造方式传入kudu的masterAddress地址.默认表名.TableSerializationSchema.KuduTableRowConv ...