MySQL 8.0权限认证(上)
create user hans@localhost identified by '123456';
grants all on *.* to 'hans'@'localhost';
show grants for hans@localhost;
revoke all on *.* from 'hans'@'localhost';
grants all on *.* to 'hans'@'192.168.1.%'
grants select on *.* to 'hans'@'192.168.1.%
grants insert,update,delete on *.* to 'hans'@'192.168.1.10%
create user 'app1'@'10.0.0.%' identified by '123456';
grant select,instert,update,delete on a1.* to 'app1'@'10.0.0.%';
grant select on a2.b2 to 'app1'@'10.0.0.%';
grant select(id) on a3.b3 to 'app1'@'10.0.0.%';
mysql> create database a1;
Query OK, 1 row affected (0.11 sec)
mysql> create database a2;
Query OK, 1 row affected (0.04 sec)
mysql> create database a3;
Query OK, 1 row affected (0.05 sec)
mysql> use a1;
Database changed
mysql> create table t1 (sid int,name varchar(10));
Query OK, 0 rows affected (0.10 sec)
mysql> use a2;
Database changed
mysql> create table b2 (sid int,name varchar(10));
Query OK, 0 rows affected (0.06 sec)
mysql> use a3;
Database changed
mysql> create table b3 (sid int,name varchar(10));
Query OK, 0 rows affected (0.41 sec)
mysql> create user 'app1'@'192.168.91.%' identified by '123456!';
Query OK, 0 rows affected (0.08 sec)
mysql> grant select,insert,update,delete on a1.* to 'app1'@'192.168.91.%';
Query OK, 0 rows affected (0.08 sec)
mysql> grant select on a2.b2 to 'app1'@'192.168.91.%';
Query OK, 0 rows affected (0.09 sec)
mysql> grant select(sid) on a3.b3 to 'app1'@'192.168.91.%';
Query OK, 0 rows affected (0.04 sec)
mysql> select * from mysql.db where user='app1' and host='192.168.91.%'\G;
*************************** 1. row ***************************
Host: 192.168.91.%
Db: a1
User: app1
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: N
Drop_priv: N
Grant_priv: N
References_priv: N
Index_priv: N
Alter_priv: N
Create_tmp_table_priv: N
Lock_tables_priv: N
Create_view_priv: N
Show_view_priv: N
Create_routine_priv: N
Alter_routine_priv: N
Execute_priv: N
Event_priv: N
Trigger_priv: N
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> select * from mysql.tables_priv where user='app1' and host='192.168.91.%'\G;
*************************** 1. row ***************************
Host: 192.168.91.%
Db: a2
User: app1
Table_name: b2
Grantor: root@localhost
Timestamp: 0000-00-00 00:00:00
Table_priv: Select
Column_priv:
*************************** 2. row ***************************
Host: 192.168.91.%
Db: a3
User: app1
Table_name: b3
Grantor: root@localhost
Timestamp: 0000-00-00 00:00:00
Table_priv:
Column_priv: Select
2 rows in set (0.00 sec)
ERROR:
No query specified
mysql> select * from mysql.columns_priv where user='app1' and host='192.168.91.%'\G;
*************************** 1. row ***************************
Host: 192.168.91.%
Db: a3
User: app1
Table_name: b3
Column_name: sid
Timestamp: 0000-00-00 00:00:00
Column_priv: Select
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> show grants for 'app1'@'192.168.91.%'\G;
*************************** 1. row ***************************
Grants for app1@192.168.91.%: GRANT USAGE ON *.* TO `app1`@`192.168.91.%`
*************************** 2. row ***************************
Grants for app1@192.168.91.%: GRANT SELECT, INSERT, UPDATE, DELETE ON `a1`.* TO `app1`@`192.168.91.%`
*************************** 3. row ***************************
Grants for app1@192.168.91.%: GRANT SELECT ON `a2`.`b2` TO `app1`@`192.168.91.%`
*************************** 4. row ***************************
Grants for app1@192.168.91.%: GRANT SELECT (`sid`) ON `a3`.`b3` TO `app1`@`192.168.91.%`
4 rows in set (0.00 sec)
ERROR:
No query specified
[root@localhost ~]# mysql -u app1 -h192.168.91.128 -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| a1 |
| a2 |
| a3 |
| information_schema |
+--------------------+
4 rows in set (0.00 sec)
MySQL [(none)]> use a2;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MySQL [a2]> insert into a2 (sid,name) values (1,'xjp');
ERROR 1142 (42000): INSERT command denied to user 'app1'@'192.168.91.129' for table 'a2'
mysql> use a3;
Database changed
mysql> show tables;
+--------------+
| Tables_in_a3 |
+--------------+
| b3 |
+--------------+
1 row in set (0.00 sec)
mysql> insert into b3 (sid,name) values (1,'xjp');
Query OK, 1 row affected (0.07 sec)
mysql> insert into b3 (sid,name) values (2,'mzd');
Query OK, 1 row affected (0.01 sec)
mysql> select * from b3;
+------+------+
| sid | name |
+------+------+
| 1 | xjp |
| 2 | mzd |
+------+------+
2 rows in set (0.00 sec)
MySQL [(none)]> use a3;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MySQL [a3]> show tables;
+--------------+
| Tables_in_a3 |
+--------------+
| b3 |
+--------------+
1 row in set (0.00 sec)
MySQL [a3]> select * from b3;
ERROR 1142 (42000): SELECT command denied to user 'app1'@'192.168.91.129' for table 'b3'
MySQL [a3]> select name from b3;
ERROR 1143 (42000): SELECT command denied to user 'app1'@'192.168.91.129' for column 'name' in table 'b3'
MySQL [a3]> select sid from b3;
+------+
| sid |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.00 sec)
mysql> revoke select on a2.b2 from 'app1'@'192.168.91.%';
Query OK, 0 rows affected (0.07 sec)
那我们再看下权限
mysql> show grants for 'app1'@'192.168.91.%'\G;
*************************** 1. row ***************************
Grants for app1@192.168.91.%: GRANT USAGE ON *.* TO `app1`@`192.168.91.%`
*************************** 2. row ***************************
Grants for app1@192.168.91.%: GRANT SELECT, INSERT, UPDATE, DELETE ON `a1`.* TO `app1`@`192.168.91.%`
*************************** 3. row ***************************
Grants for app1@192.168.91.%: GRANT SELECT (`sid`) ON `a3`.`b3` TO `app1`@`192.168.91.%`
3 rows in set (0.00 sec)
ERROR:
No query specified
[root@localhost ~]# mysql -u app1 -h192.168.91.128 -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| a1 |
| a3 |
| information_schema |
+--------------------+
3 rows in set (0.00 sec)
MySQL [(none)]> use a2;
ERROR 1044 (42000): Access denied for user 'app1'@'192.168.91.%' to database 'a2'
MySQL 8.0权限认证(上)的更多相关文章
- MySQL 8.0权限认证(下)
MySQL 8.0权限认证(下) 一.设置MySQL用户资源限制 通过设置全局变量max_user_connections可以限制所有用户在同一时间连接MySQL实例的数量,但此参数无法对每个 ...
- MySQL 8.0有什么新功能
https://mysqlserverteam.com/whats-new-in-mysql-8-0-generally-available/ 我们自豪地宣布MySQL 8.0的一般可用性. 现在下载 ...
- CentOS 6.6 MySQL 8.0详细安装步骤
1.备份服务器上MySQL数据库 [root@localhost ] # mysqldump -h localhost -u root -proot --databases Surpass --rou ...
- 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权限认证 ...
- asp.net权限认证:OWIN实现OAuth 2.0 之简化模式(Implicit)
asp.net权限认证系列 asp.net权限认证:Forms认证 asp.net权限认证:HTTP基本认证(http basic) asp.net权限认证:Windows认证 asp.net权限认证 ...
- MySQL 8.0.14 新的密码认证方式和客户端链接
MySQL 8.0.14 新的密码认证方式和客户端链接 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. MySQL8.0在密码认证方式发生了改变,这也是有点小伙伴在MySQL创建 ...
- 阿里云CentOS自动备份MySql 8.0并上传至七牛云
本文主要介绍一下阿里云CentOS7下如何对MySql 8.0数据库进行自动备份,并使用.NET Core 将备份文件上传至七牛云存储上,并对整个过程所踩的坑加以记录. 环境.工具.准备工作 服务器: ...
- elasticsearch shield(5.0以下版本 权限认证)
elasticsearch 5.0以下的版本要用到权限控制的话需要使用shield.下载地址: https://www.elastic.co/downloads/shield5.0以上的版本则可以使用 ...
随机推荐
- 【雕爷学编程】Arduino动手做(57)---四档矩形波模块
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里 ...
- 弹性式数据集RDD
弹性式数据集RDD 一.RDD简介二.创建RDD 2.1 由现有集合创建 2.2 引用外部存储系统中的数据集 2.3 textFile & who ...
- 【遗传编程/基因规划】Genetic Programming
目录 背景介绍 程序表示 初始化 (Initialization) Depth定义 Grow方法 Full方法 Ramped half-and-half方法 适应度(Fitness)与选择(Selec ...
- Django之ORM中事务和锁
ORM事务: 事务: 数据库事务(简称:事务)是数据库管理系统执行过程中的一个逻辑单位,由一个有限的数据库操作序列构成. 事务的特点: 并非任意的对数据库的操作序列都是数据库事务.数据库事务拥有以下四 ...
- ThreadLocal 内存泄漏问题深入分析
写在前面 ThreadLocal 基本用法本文就不介绍了,如果有不知道的小伙伴可以先了解一下,本文只研究 ThreadLocal 内存泄漏这一问题. ThreadLocal 会发生内存泄漏吗? 先给出 ...
- antd自定义样式主题
参考网址: https://blog.csdn.net/focusdroid/article/details/85381042 链接: 这篇文章:(#*3 and #*4)借鉴@钱锋这位童鞋,如有侵权 ...
- dTree
1.dtree.js源码 /*--------------------------------------------------| | dTree 2.05 | www.destroydrop.co ...
- 走迷宫(三):在XX限制条件下,是否走得出。
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010 题目前提条件:让你输入一个数组,包含一个起点S,一个终点D,一个时间T.(其中X代表墙,.代表此 ...
- Android | 超简单集成HMS ML Kit实现最大脸微笑抓拍
前言 如果大家对HMS ML Kit 人脸检测功能有所了解,相信已经动手调用我们提供的接口编写自己的APP啦.目前就有小伙伴在调用接口的过程中反馈,不太清楚HMS ML Kit 文档中的MLMax ...
- 【解构云原生】初识Kubernetes Service
编者按:云原生是网易杭州研究院(网易杭研)奉行的核心技术方向之一,开源容器平台Kubernetes作为云原生产业技术标准.云原生生态基石,在设计上不可避免有其复杂性,Kubernetes系列文章基于网 ...