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以上的版本则可以使用 ...
随机推荐
- nginx default server
配合server_name _ 可以匹配所有的域名,在设置default server 可以轻松屏蔽一些非域名访问的请求. 配置如下 server { listen 80 default_server ...
- git:error: Your local changes to the following files would be overwritten by merge:
最近用git在服务器.github.本地更新代码的时候,因为频繁修改偶尔出现这个错误 覆盖本地的代码: git stash git pull git stash pop 保留对服务器上的修改: git ...
- chrome "items hidden by filters"
今天更新chrome 后遇到console不能显示errors的问题,折腾一番后发现在console的Default levels中选择Default即可.
- C# 操作Orcle数据库
1.首先添加NuGet:Oracle.ManagedDataAccess 2.配置连接数据库字符串:Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(H ...
- nodejs链接mysql 中的问题
首先你得对mysql ,有个大概的认识. 比如说:如何安装,使用基本的语法,测试安装是否能成功,以及成功之后简单的对于数据库的,操作(增删改查)... 下面是业务场景:在爬虫过程中,租后需要将信息输出 ...
- {dede:channelartlist} 改变偶数的class
{dede:channelartlist} <div {dede:global.itemindex runphp='yes'} if((@me %2) == 0){ @me = 'class=& ...
- PHP SESSION 操作
Session的声明与使用 Session的设置不同于Cookie,必须先启动,在PHP中必须调用session_start().session_start()函数的语法格式如下: Bool sess ...
- ubuntu 下安装 mysql 启动报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
环境: ubuntu LTS 18.04.1 mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64) 初探 linux,按照如下安装完mysql sudo ...
- [JavaWeb基础] 012.Struts2 自定义标签使用
在做开发中,我们会把一些比较经常使用到的代码封装起来,这样可以加快开发的速度和减少错误,并且在修改bug可以一次修改多次修复.那么在前端页面上,如果我们要经常用到公用的显示功能,并涉及到服务端逻辑操作 ...
- HDL-数字电路建模的要点
https://mp.weixin.qq.com/s/tEDMWf1gk0e7u4hIWKM9bQ 一. 拓扑 数字电路的拓扑抽象出来之后比较简单,就是线(Wire)和开关(Swit ...