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开启远程访问权限,防 ...
随机推荐
- STM32学习笔记——USART
STM32的USART组件支持异步.同步.单线半双工.多处理器.IrDA.LIN.SmartCard等模式,本文介绍的是异步即UART模式. 总线通信有三种模型:轮询.中断和DMA.DMA对我来说是陌 ...
- 51Nod1127 最小包含字符串
51Nod1127 #include <iostream> #include <string> using namespace std; const int inf = 0x3 ...
- 【谎言大揭秘】Modin真的比pandas运行更快吗?
最近看了某公众号文章,推荐了所谓的神器,据说读取速度吊打pandas,可谓牛逼,事实真是这样吗? 来一起揭秘真相. 首先安装包. # pip install ray # pip install das ...
- Java术语
- Vue中计算属性(computed)和监听属性函数watch的比较
1.计算属性适用的情形我们可能会有这样的需求,一个数据属性在它所依赖的属性发生变化时,也要发生变化,这种情况下,我们最好使用计算属性.例如在下面这个例子中,如果我们使用监听函数,代码就会变得有点冗余. ...
- 安装superset遇到的坑
实验环境:ubuntu16.04 python环境: 3.6.7 安装参考:https://superset.incubator.apache.org/installation.html 特别提醒: ...
- TensorFlow的checkpoint文件转换为pb文件
由于项目需要,需要将TensorFlow保存的模型从ckpt文件转换为pb文件. import os from tensorflow.python import pywrap_tensorflow f ...
- 跟着阿里学JavaDay01——Java编程环境搭建
一.下载并完成JDK的安装 我们要学习Java就需要下载JDK.因为JDK是Java的开发工具. JDK的获取可以通过官方网站下载:JDK下载地址(这里我们下载Java SE10的版本) JDK下载完 ...
- GitHub+jsDelivr+PicGo 打造稳定快速、高效免费图床
标题: GitHub+jsDelivr+PicGo 打造稳定快速.高效免费图床 作者: 梦幻之心星 347369787@QQ.com 标签: [GitHub, 图床] 目录: 图床 日期: 2019- ...
- MySQL8.0 忘记密码、重置密码
修改my.cnf [mysqld] 域中添加skip-grant-tables 重启mysqld服务 systemctl restart mysqld 重新使用空密码登录,直接敲回车 mysql -u ...