DROP DATABASE IF EXISTS test1;
DROP DATABASE IF EXISTS test2;
CREATE DATABASE test1;
CREATE DATABASE test2;
CREATE TABLE test1.t1  (f1 VARCHAR(20)) ENGINE = <engine_to_be_used>;
CREATE TABLE test1.t2  (f1 VARCHAR(20)) ENGINE = <engine_to_be_used>;
CREATE TABLE test2.t1 (f1 VARCHAR(20)) ENGINE = <engine_to_be_used>;
SELECT *,
LEFT( table_comment,
IF(INSTR(table_comment,'InnoDB free') = 0
AND INSTR(table_comment,'number_of_replicas') = 0,
LENGTH(table_comment),
INSTR(table_comment,'InnoDB free')
+ INSTR(table_comment,'number_of_replicas') - 1))
AS "user_comment",
'-----------------------------------------------------' AS "Separator"
FROM information_schema.tables
WHERE table_schema LIKE 'test%' AND table_type = 'BASE TABLE'
ORDER BY table_schema,table_name;
TABLE_CATALOG	NULL
TABLE_SCHEMA	test1
TABLE_NAME	t1
TABLE_TYPE	BASE TABLE
ENGINE	ndbcluster
VERSION	10
ROW_FORMAT	Dynamic
TABLE_ROWS	#TBLR#
AVG_ROW_LENGTH	#ARL#
DATA_LENGTH	#DL#
MAX_DATA_LENGTH	#MDL#
INDEX_LENGTH	#IL#
DATA_FREE	#DF#
AUTO_INCREMENT	NULL
CREATE_TIME	#CRT#
UPDATE_TIME	#UT#
CHECK_TIME	#CT#
TABLE_COLLATION	latin1_swedish_ci
CHECKSUM	NULL
CREATE_OPTIONS	#CO#
TABLE_COMMENT	#TC#
user_comment	
Separator	-----------------------------------------------------
TABLE_CATALOG	NULL
TABLE_SCHEMA	test1
TABLE_NAME	t2
TABLE_TYPE	BASE TABLE
ENGINE	ndbcluster
VERSION	10
ROW_FORMAT	Dynamic
TABLE_ROWS	#TBLR#
AVG_ROW_LENGTH	#ARL#
DATA_LENGTH	#DL#
MAX_DATA_LENGTH	#MDL#
INDEX_LENGTH	#IL#
DATA_FREE	#DF#
AUTO_INCREMENT	NULL
CREATE_TIME	#CRT#
UPDATE_TIME	#UT#
CHECK_TIME	#CT#
TABLE_COLLATION	latin1_swedish_ci
CHECKSUM	NULL
CREATE_OPTIONS	#CO#
TABLE_COMMENT	#TC#
user_comment	
Separator	-----------------------------------------------------
TABLE_CATALOG	NULL
TABLE_SCHEMA	test2
TABLE_NAME	t1
TABLE_TYPE	BASE TABLE
ENGINE	ndbcluster
VERSION	10
ROW_FORMAT	Dynamic
TABLE_ROWS	#TBLR#
AVG_ROW_LENGTH	#ARL#
DATA_LENGTH	#DL#
MAX_DATA_LENGTH	#MDL#
INDEX_LENGTH	#IL#
DATA_FREE	#DF#
AUTO_INCREMENT	NULL
CREATE_TIME	#CRT#
UPDATE_TIME	#UT#
CHECK_TIME	#CT#
TABLE_COLLATION	latin1_swedish_ci
CHECKSUM	NULL
CREATE_OPTIONS	#CO#
TABLE_COMMENT	#TC#
user_comment	
Separator	-----------------------------------------------------
SHOW TABLES FROM test1;
Tables_in_test1
t1
t2
SHOW TABLES FROM test2;
Tables_in_test2
t1
DROP   USER testuser1@localhost;
CREATE USER testuser1@localhost;
GRANT SELECT ON test1.* TO testuser1@localhost;
# Establish connection testuser1 (user=testuser1)
SELECT *,
LEFT( table_comment,
IF(INSTR(table_comment,'InnoDB free') = 0
AND INSTR(table_comment,'number_of_replicas') = 0,
LENGTH(table_comment),
INSTR(table_comment,'InnoDB free')
+ INSTR(table_comment,'number_of_replicas') - 1))
AS "user_comment",
'-----------------------------------------------------' AS "Separator"
FROM information_schema.tables
WHERE table_schema LIKE 'test%' AND table_type = 'BASE TABLE'
ORDER BY table_schema,table_name;
TABLE_CATALOG	NULL
TABLE_SCHEMA	test1
TABLE_NAME	t1
TABLE_TYPE	BASE TABLE
ENGINE	ndbcluster
VERSION	10
ROW_FORMAT	Dynamic
TABLE_ROWS	#TBLR#
AVG_ROW_LENGTH	#ARL#
DATA_LENGTH	#DL#
MAX_DATA_LENGTH	#MDL#
INDEX_LENGTH	#IL#
DATA_FREE	#DF#
AUTO_INCREMENT	NULL
CREATE_TIME	#CRT#
UPDATE_TIME	#UT#
CHECK_TIME	#CT#
TABLE_COLLATION	latin1_swedish_ci
CHECKSUM	NULL
CREATE_OPTIONS	#CO#
TABLE_COMMENT	#TC#
user_comment	
Separator	-----------------------------------------------------
TABLE_CATALOG	NULL
TABLE_SCHEMA	test1
TABLE_NAME	t2
TABLE_TYPE	BASE TABLE
ENGINE	ndbcluster
VERSION	10
ROW_FORMAT	Dynamic
TABLE_ROWS	#TBLR#
AVG_ROW_LENGTH	#ARL#
DATA_LENGTH	#DL#
MAX_DATA_LENGTH	#MDL#
INDEX_LENGTH	#IL#
DATA_FREE	#DF#
AUTO_INCREMENT	NULL
CREATE_TIME	#CRT#
UPDATE_TIME	#UT#
CHECK_TIME	#CT#
TABLE_COLLATION	latin1_swedish_ci
CHECKSUM	NULL
CREATE_OPTIONS	#CO#
TABLE_COMMENT	#TC#
user_comment	
Separator	-----------------------------------------------------
SHOW TABLES FROM test1;
Tables_in_test1
t1
t2
SHOW TABLES FROM test2;
ERROR 42000: Access denied for user 'testuser1'@'localhost' to database 'test2'
# Switch to connection default and close connection testuser1
DROP USER testuser1@localhost;
DROP DATABASE test1;
DROP DATABASE test2;
