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开启远程访问权限,防 ...
随机推荐
- 修改jupyter默认保存文件的目录
1.打开 Anaconda Prompt输入命令 jupyter notebook --generate-config 2.可以看到生成了目录及jupyter notebook的配置文件,打开该文件. ...
- sonar 安装,centos7配置优化
/etc/sysctl.conf /etc/systemd/system.conf /etc/security/limits.conf /proc/sys/fs/file-max /etc/secur ...
- Java创建线程的方式
Java中线程的创建有四i种方式: 1. 通过继承Thread类,重写Thread的run()方法,将线程运行的逻辑放在其中 2. 通过实现Runnable接口,实例化Thread类 3.应用程序 ...
- Quartz3.0定时任务学习之异步调度器
前言 Quartz3与Quartz2的主要区别有两点: 1,Quartz3将它的资源类库拆的更细了,比如,想使用Quartz3开发,最少要引用Quartz,Quartz.Jobs,Quartz.Plu ...
- Git基本操作命令合集
平时自己敲敲代码,使用Git命令也渐渐多了起来.使用起来的确很方便,今天来分享下Git基本概念和本地代码提交到github上的过程,很简单的,多操作几次就会了. Git定义 Git 是一个开源的分布式 ...
- nginx四种均衡策略
1.基于轮询的均衡策略: 轮询嘛,就是说对进到nginx的request按照遍历的方式进行分发,如果request 1 分发到 Server A,那么request 2将被分发到 Server B,. ...
- [PHP学习教程 - 文件]001.高速读写大数据“二进制”文件,不必申请大内存(Byte Block)
引言:读写大“二进制”文件,不必申请很大内存(fopen.fread.fwrite.fclose)!做到开源节流,提高速度! 每天告诉自己一次,『我真的很不错』.... 加速读写大文件,在实际工作过程 ...
- 插入与读取Blob类型数据
BlobTest package com.aff.PreparedStatement; import java.io.File; import java.io.FileInputStream; imp ...
- 2020本科校招-从小白到拿到30k offer的学习经历
本文是个人的2020年年中总结 还有十几天就要毕业,面临着身份从学生到互联网社畜的转变,未来的一切捉摸不定,但凡心中万千情绪,也只能「但行好事,莫问前程」. 介绍下博主背景:计算机本科大四,刚进大三时 ...
- Spring boot Sample 0010之spring-boot-web-freemarker
一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 spring boot 整合freemarker模板开发web项目 三.步骤 3.1.点击File -> New Pr ...