Mysql 数据库模拟客户端工具小技巧

脚本方式:
-- 通过脚本循环db变量传值,结合information_schema.`TABLES`统计
-- Warning 提示输出到2>/dev/null,明文密码还可以配置到my.cnf中,就不会有提示了!
# for dbs in `mysql hive -h x.x.x.x -uuser -ppass -e "show databases;" 2>/dev/null| sed '1,2d' | egrep -v "mysql|schema"`; do mysql hive -h x.x.x.x -uuser -ppass -e "select count(*), table_schema from information_schema.tables where table_schema = '$dbs' GROUP BY table_schema;" 2>/dev/null;done

 Mysql 数据库模拟客户端工具小技巧_第1张图片

sql语句方式
-- 通过information_schema.`TABLES`统计
SELECT table_schema, COUNT(*) AS db_has_tableCounts FROM information_schema.`TABLES` WHERE table_schema NOT IN ('mysql','information_schema','performance_schema','\(NULL\)') GROUP BY table_schema;

Mysql 数据库模拟客户端工具小技巧_第2张图片

 

 

你可能感兴趣的:(mysql)