1drop database if exists db;
2Warnings:
3Note	1008	Can't drop database 'db'; database doesn't exist
4create role r1;
5create user beep@'%';
6create database db;
7create table db.t1 (i int);
8create table db.t2 (b int);
9grant select on db.* to r1;
10grant r1 to beep@'%';
11connect  con1,localhost,beep,,;
12show databases;
13Database
14information_schema
15test
16show create database db;
17ERROR 42000: Access denied for user 'beep'@'localhost' to database 'db'
18select table_schema, table_name from information_schema.tables
19where table_schema = 'db' order by table_name;
20table_schema	table_name
21set role r1;
22show databases;
23Database
24db
25information_schema
26test
27show create database db;
28Database	Create Database
29db	CREATE DATABASE `db` /*!40100 DEFAULT CHARACTER SET latin1 */
30select table_schema, table_name from information_schema.tables
31where table_schema = 'db' order by table_name;
32table_schema	table_name
33db	t1
34db	t2
35connection default;
36create role r2;
37create user beep2@'%';
38grant update on db.* to r2;
39grant r2 to beep2;
40connect  con2,localhost,beep2,,;
41show databases;
42Database
43information_schema
44test
45show create database db;
46ERROR 42000: Access denied for user 'beep2'@'localhost' to database 'db'
47select table_schema, table_name from information_schema.tables
48where table_schema = 'db' order by table_name;
49table_schema	table_name
50set role r2;
51show databases;
52Database
53db
54information_schema
55test
56show create database db;
57Database	Create Database
58db	CREATE DATABASE `db` /*!40100 DEFAULT CHARACTER SET latin1 */
59select table_schema, table_name from information_schema.tables
60where table_schema = 'db' order by table_name;
61table_schema	table_name
62db	t1
63db	t2
64connection default;
65drop database db;
66drop role r1;
67drop user beep;
68drop role r2;
69drop user beep2;
70