巡检项目

  • 表检查

    • 超过10G大表

    • 索引数目超过8个的表

    • 碎片超过1G的表

    • 单表超过2000万的表

    • 非默认字符集表

    • 大字段表

    • 字段长度过大的表

    • 无主键/索引表

  • 索引检查

    • 重复索引

    • 字段过多索引

    • 未使用的索引

  • 参数检查

    • version

    • innodb_buffer_pool_size

    • innodb_flush_log_at_trx_commit

    • innodb_log_file_size

    • innodb_log_files_in_group

    • innodb_file_per_table

    • innodb_open_files

    • innodb_data_home_dir

    • innodb_flush_method

    • innodb_max_dirty_pages_pct

    • sync_binlog

    • max_connections

    • query_cache_type

    • sort_buffer_size

    • read_buffer_size

    • max_allowed_packet

    • table_open_cache

    • thread_cache_size

    • innodb_thread_concurrency

    • key_buffer_size

    • 字符集

    • time_zone

    • 默认存储引擎

  • 状态检查

    • opend_files

    • opend_tables

    • max_used_connections

  • 安全检查

    • 匿名账户

    • 无密码账户

    • 未限制来源ip账户

    • 高权限账户

Python版本巡检脚本:

  1. #!/usr/bin/env python
  2. #-*- coding:utf-8 -*-
  3. import os
  4. import MySQLdb as mdb
  5. import time,datetime
  6. import re
  7. from passde import encrypt, decrypt
  8. conn = mdb.connect(host='127.0.0.1', port=3306, user='root', passwd=decrypt('776ebdb8d0430e24b5bb751476c01417'), db='jumpmysql', charset='utf8')
  9. cursor = conn.cursor()
  10. print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  11. print "++ MySQL Check report ++"
  12. print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  13. print "start time: %s" % datetime.datetime.now()
  14. #table_check
  15. print '''
  16. ----------------------------------------------------------------------------------------------------------------
  17. start table check
  18. 1.size
  19. 2.much indexes
  20. 3.fragment
  21. 4.rows
  22. 5.charset
  23. 6.big column
  24. 7.long column
  25. 8.no indexes
  26. ----------------------------------------------------------------------------------------------------------------
  27. '''
  28. #get tables more than 10G
  29. cursor.execute("select table_schema,table_name,concat(round((data_length+index_length)/1024/1024,2),'M') FROM \
  30. information_schema.tables where (DATA_LENGTH+INDEX_LENGTH) > 10*1024*1024*1024 and table_schema not in \
  31. ('information_schema','mysql','performance_schema','sys')")
  32. table_size = cursor.fetchall()
  33. print "\033[1;33;44m 1: result of table is more than 10G\033[0m"
  34. if table_size:
  35. for table in table_size:
  36. table_schema = table[0]
  37. table_name = table[1]
  38. size = table[2]
  39. print " table_schema: %-20s table_name : %-20s size: %10s " % \
  40. (table_schema, table_name, size)
  41. else:
  42. print "no table is more than 10G"
  43. #get tables which have more than 6 indexes
  44. cursor.execute("select t1.name,t2.num from information_schema.innodb_sys_tables t1, (select table_id,count(*) as num from \
  45. information_schema.innodb_sys_indexes group by table_id having count(*) >=6) t2 where t1.table_id =t2.table_id")
  46. table_index = cursor.fetchall()
  47. print "\033[1;33;44m 2: result of table more than 6 indexes\033[0m"
  48. if table_index:
  49. for table in table_index:
  50. table_name = table[0]
  51. index_num = table[1]
  52. print " table_name: %-50s index_num: %10d " % \
  53. (table_name, index_num)
  54. else:
  55. print "no table has more than 6 indexes"
  56. #get tables which have big fragment
  57. cursor.execute("select table_schema,table_name,DATA_FREE from \
  58. information_schema.TABLES where table_schema not in ('information_schema','mysql','performance_schema','sys') \
  59. and data_free > 1*1024*1024*1024 order by DATA_FREE desc;")
  60. table_fragment = cursor.fetchall()
  61. print "\033[1;33;44m 3: result of table has big fragment\033[0m"
  62. if table_fragment:
  63. for table in table_fragment:
  64. table_schema = table[0]
  65. table_name = table[1]
  66. data_free = table[2]
  67. print " table_schema: %-20s table_name : %-20s fragment: %10s " % \
  68. (table_schema, table_name, data_free)
  69. else:
  70. print "no table has big fragment"
  71. #get tables which have 20000000 rows
  72. cursor.execute("select table_schema,table_name,table_rows from \
  73. information_schema.TABLES where table_schema not in ('information_schema','mysql','performance_schema','sys') \
  74. and table_rows > 20000000 order by table_rows desc;")
  75. table_fragment = cursor.fetchall()
  76. print "\033[1;33;44m 4: result of table has more than 20000000 rows\033[0m"
  77. if table_fragment:
  78. for table in table_fragment:
  79. table_schema = table[0]
  80. table_name = table[1]
  81. table_rows = table[2]
  82. print " table_schema: %-20s table_name : %-20s table_rows: %10d " % \
  83. (table_schema, table_name, table_rows)
  84. else:
  85. print "no table has has more than 20000000 rows"
  86. #get table charset not default
  87. cursor.execute("show variables like 'character_set_server';")
  88. default_charset = str(cursor.fetchone()[1])
  89. default_charset = default_charset+"_general_ci"
  90. sql = "select table_schema,table_name,table_collation from information_schema.tables where table_schema not \
  91. in ('information_schema','mysql','performance_schema','sys') and table_collation !='"+default_charset+"';"
  92. cursor.execute(sql)
  93. table_charset = cursor.fetchall()
  94. print "\033[1;33;44m 5: result of table is not in default charset\033[0m"
  95. if table_charset:
  96. for table in table_charset:
  97. table_schema = table[0]
  98. table_name = table[1]
  99. charset = table[2]
  100. print " table_schema: %-20s table_name : %-20s charset: %10s " % \
  101. (table_schema, table_name, charset)
  102. else:
  103. print "no table is not in default charset"
  104. #get tables which have big columns
  105. cursor.execute("select table_schema,table_name,column_name,data_type from information_schema.columns where data_type in \
  106. ('blob','clob','text','medium text','long text') and table_schema not in \
  107. ('information_schema','performance_schema','mysql','sys')")
  108. table_big_cols = cursor.fetchall()
  109. print "\033[1;33;44m 6: result of table has big columns\033[0m"
  110. if table_big_cols:
  111. for table in table_big_cols:
  112. table_schema = table[0]
  113. table_name = table[1]
  114. column_name = table[2]
  115. data_type = table[3]
  116. print " table_schema: %-20s table_name : %-20s column_name: %-20s data_type: %-20s" % \
  117. (table_schema, table_name, column_name, data_type)
  118. else:
  119. print "no table has has big columns"
  120. #get tables which have long varchar columns
  121. cursor.execute("select table_schema,table_name,column_name,data_type,CHARACTER_MAXIMUM_LENGTH from information_schema.columns \
  122. where DATA_TYPE='varchar' and CHARACTER_MAXIMUM_LENGTH > 500 and table_schema not in \
  123. ('information_schema','performance_schema','mysql','sys');")
  124. table_long_cols = cursor.fetchall()
  125. print "\033[1;33;44m 7: result of table has long columns\033[0m"
  126. if table_long_cols:
  127. for table in table_long_cols:
  128. table_schema = table[0]
  129. table_name = table[1]
  130. column_name = table[2]
  131. data_type = table[3]
  132. CHARACTER_MAXIMUM_LENGTH = table[4]
  133. print " table_schema: %-20s table_name : %-20s column_name: %-20s data_type: %-20s length: %-5s" % \
  134. (table_schema, table_name, column_name, data_type, CHARACTER_MAXIMUM_LENGTH)
  135. else:
  136. print "no table has has big columns"
  137. #get tables which have not indexes
  138. cursor.execute("SELECT t.table_schema,t.table_name FROM information_schema.tables AS t LEFT JOIN \
  139. (SELECT DISTINCT table_schema, table_name FROM information_schema.`KEY_COLUMN_USAGE` ) AS kt ON \
  140. kt.table_schema=t.table_schema AND kt.table_name = t.table_name WHERE t.table_schema NOT IN \
  141. ('mysql', 'information_schema', 'performance_schema', 'sys') AND kt.table_name IS NULL;")
  142. table_not_indexes = cursor.fetchall()
  143. print "\033[1;33;44m 8: result of table has not indexes\033[0m"
  144. if table_not_indexes:
  145. for table in table_not_indexes:
  146. table_schema = table[0]
  147. table_name = table[1]
  148. print " table_schema: %-20s table_name : %-20s " % \
  149. (table_schema, table_name)
  150. else:
  151. print "all tables have indexes"
  152. # time.sleep(5)
  153. # index check
  154. print '''
  155. ----------------------------------------------------------------------------------------------------------------
  156. start index check
  157. 1.redundant indexes
  158. 2.to much columns indexes
  159. 3.unused indexes
  160. ----------------------------------------------------------------------------------------------------------------
  161. '''
  162. #redundant indexes
  163. cursor.execute("select table_schema,table_name,redundant_index_name,redundant_index_columns \
  164. from sys.schema_redundant_indexes;")
  165. redundant_indexes = cursor.fetchall()
  166. print "\033[1;33;44m 1: result of redundant indexes\033[0m"
  167. if redundant_indexes:
  168. for index in redundant_indexes:
  169. table_schema = index[0]
  170. table_name = index[1]
  171. index_name = index[2]
  172. column_name = index[3]
  173. print " table_schema: %-20s table_name: %-20s index_name: %-20s column_name:%-20s" % \
  174. (table_schema, table_name, index_name, column_name)
  175. else:
  176. print "no redundant indexes"
  177. #to much columns indexes
  178. cursor.execute("select s.table_schema,s.table_name,s.index_name,s.column_name from information_schema.STATISTICS s,\
  179. (select table_name,index_name,count(*) from information_schema.STATISTICS where table_schema not in \
  180. ('information_schema','performance_schema','mysql','sys') group by table_name,index_name having count(*)>5)t where \
  181. s.table_name=t.table_name and s.index_name=t.index_name;")
  182. to_much_columns_indexes = cursor.fetchall()
  183. print "\033[1;33;44m 2: result of to much columns indexes\033[0m"
  184. if to_much_columns_indexes:
  185. for index in to_much_columns_indexes:
  186. table_schema = index[0]
  187. table_name = index[1]
  188. index_name = index[2]
  189. column_name = index[3]
  190. print " table_schema: %-20s table_name: %-20s index_name: %-20s column_name:%-20s" % \
  191. (table_schema, table_name, index_name, column_name)
  192. else:
  193. print "all index have column under 5"
  194. #unused indexes
  195. cursor.execute("select * from sys.schema_unused_indexes;")
  196. unused_indexes = cursor.fetchall()
  197. print "\033[1;33;44m 3: result of redundant indexes\033[0m"
  198. if unused_indexes:
  199. for index in unused_indexes:
  200. table_schema = index[0]
  201. table_name = index[1]
  202. index_name = index[2]
  203. print " table_schema: %-20s table_name: %-20s index_name: %-20s" % \
  204. (table_schema, table_name, index_name)
  205. else:
  206. print "no unused indexes"
  207. print '''
  208. ----------------------------------------------------------------------------------------------------------------
  209. start variables check
  210. 1.version
  211. 2.innodb_buffer_pool_size
  212. 3.innodb_flush_log_at_trx_commit
  213. 4.innodb_log_file_size
  214. 5.innodb_log_files_in_group
  215. 6.innodb_file_per_table
  216. 7.innodb_open_files
  217. 8.innodb_data_home_dir
  218. 9.innodb_flush_method
  219. 10.innodb_max_dirty_pages_pct
  220. 11.sync_binlog
  221. 12.max_connections
  222. 13.query_cache_type
  223. 14.sort_buffer_size
  224. 15.read_buffer_size
  225. 16.max_allowed_packet
  226. 17.table_open_cache
  227. 18.thread_cache_size
  228. 19.key_buffer_size
  229. 20.charset
  230. 21.time_zone
  231. 22.default storage engine
  232. ----------------------------------------------------------------------------------------------------------------
  233. '''
  234. #1.mysql_version
  235. sql_version = "select version();"
  236. cursor.execute(sql_version)
  237. data = cursor.fetchone()
  238. mysql_version = data[0]
  239. print "mysql_version: %-30s" % mysql_version
  240. #2.innodb_buffer_pool_size
  241. sql_innodb_buffer_pool_size = "show global variables like 'innodb_buffer_pool_size'"
  242. cursor.execute(sql_innodb_buffer_pool_size)
  243. data = cursor.fetchone()
  244. innodb_buffer_pool_size = int(data[1])/1024/1024
  245. print "innodb_buffer_pool_size: %f M" % innodb_buffer_pool_size
  246. #3.innodb_flush_log_at_trx_commit
  247. sql_innodb_flush_log_at_trx_commit = "show global variables like 'innodb_flush_log_at_trx_commit'"
  248. cursor.execute(sql_innodb_flush_log_at_trx_commit)
  249. data = cursor.fetchone()
  250. innodb_flush_log_at_trx_commit = data[1]
  251. print "innodb_flush_log_at_trx_commit: %s" % innodb_flush_log_at_trx_commit
  252. #4.innodb_log_file_size
  253. sql_innodb_log_file_size = "show global variables like 'innodb_log_file_size'"
  254. cursor.execute(sql_innodb_log_file_size)
  255. data = cursor.fetchone()
  256. innodb_log_file_size = int(data[1])/1024/1024
  257. print "innodb_log_file_size: %s M" % innodb_log_file_size
  258. #5.innodb_log_files_in_group
  259. sql_innodb_log_files_in_group = "show global variables like 'innodb_log_files_in_group'"
  260. cursor.execute(sql_innodb_log_files_in_group)
  261. data = cursor.fetchone()
  262. innodb_log_files_in_group = data[1]
  263. print "innodb_log_files_in_group: %s" % innodb_log_files_in_group
  264. #6.innodb_file_per_table
  265. sql_innodb_file_per_table = "show global variables like 'innodb_file_per_table'"
  266. cursor.execute(sql_innodb_file_per_table)
  267. data = cursor.fetchone()
  268. innodb_file_per_table = data[1]
  269. print "innodb_file_per_table: %s" % innodb_file_per_table
  270. #7.innodb_open_files
  271. sql_innodb_open_files = "show global variables like 'innodb_open_files'"
  272. cursor.execute(sql_innodb_open_files)
  273. data = cursor.fetchone()
  274. innodb_open_files = data[1]
  275. print "innodb_open_files: %s" % innodb_open_files
  276. #8.innodb_data_home_dir
  277. sql_innodb_data_home_dir = "show global variables like 'datadir'"
  278. cursor.execute(sql_innodb_data_home_dir)
  279. data = cursor.fetchone()
  280. datadir = data[1]
  281. print "innodb_data_home_dir: %s" % datadir
  282. #9.innodb_flush_method
  283. sql_innodb_flush_method = "show global variables like 'innodb_flush_method'"
  284. cursor.execute(sql_innodb_flush_method)
  285. data = cursor.fetchone()
  286. innodb_flush_method = data[1]
  287. print "innodb_flush_method: %s" % innodb_flush_method
  288. #10.innodb_max_dirty_pages_pct
  289. sql_innodb_max_dirty_pages_pct = "show global variables like 'innodb_max_dirty_pages_pct'"
  290. cursor.execute(sql_innodb_max_dirty_pages_pct)
  291. data = cursor.fetchone()
  292. innodb_max_dirty_pages_pct = data[1]
  293. print "innodb_max_dirty_pages_pct: %s" % innodb_max_dirty_pages_pct
  294. #11.sync_binlog
  295. sql_sync_binlog = "show global variables like 'sync_binlog'"
  296. cursor.execute(sql_sync_binlog)
  297. data = cursor.fetchone()
  298. sync_binlog = data[1]
  299. print "sync_binlog: %s" % sync_binlog
  300. #12.max_connections
  301. sql_max_connections = "show global variables like 'max_connections'"
  302. cursor.execute(sql_max_connections)
  303. data = cursor.fetchone()
  304. max_connections = data[1]
  305. print "max_connections: %s" % max_connections
  306. #13.query_cache_type
  307. sql_query_cache_type = "show global variables like 'query_cache_type'"
  308. cursor.execute(sql_query_cache_type)
  309. data = cursor.fetchone()
  310. query_cache_type = data[1]
  311. print "query_cache_type: %s" % query_cache_type
  312. #14.sort_buffer_size
  313. sql_sort_buffer_size = "show global variables like 'sort_buffer_size'"
  314. cursor.execute(sql_sort_buffer_size)
  315. data = cursor.fetchone()
  316. sort_buffer_size = float(data[1])/1024/1024
  317. print "sort_buffer_size: %f M" % sort_buffer_size
  318. #15.read_buffer_size
  319. sql_read_buffer_size = "show global variables like 'read_buffer_size'"
  320. cursor.execute(sql_read_buffer_size)
  321. data = cursor.fetchone()
  322. read_buffer_size = float(data[1])/1024/1024
  323. print "read_buffer_size: %f M" % read_buffer_size
  324. #16.max_allowed_packet
  325. sql_max_allowed_packet = "show global variables like 'max_allowed_packet'"
  326. cursor.execute(sql_max_allowed_packet)
  327. data = cursor.fetchone()
  328. max_allowed_packet = float(data[1])/1024/1024
  329. print "max_allowed_packet: %f M" % max_allowed_packet
  330. #17.table_open_cache
  331. sql_table_open_cache = "show global variables like 'table_open_cache'"
  332. cursor.execute(sql_table_open_cache)
  333. data = cursor.fetchone()
  334. table_open_cache = data[1]
  335. print "table_open_cache: %s" % table_open_cache
  336. #18.thread_cache_size
  337. sql_thread_cache_size = "show global variables like 'thread_cache_size'"
  338. cursor.execute(sql_thread_cache_size)
  339. data = cursor.fetchone()
  340. thread_cache_size = data[1]
  341. print "thread_cache_size: %s" % thread_cache_size
  342. #19.key_buffer_size
  343. sql_key_buffer_size = "show global variables like 'key_buffer_size'"
  344. cursor.execute(sql_key_buffer_size)
  345. data = cursor.fetchone()
  346. key_buffer_size = float(data[1])/1024/1024
  347. print "key_buffer_size: %f M" % key_buffer_size
  348. #20.charset
  349. sql_character_set_server = "show global variables like 'character_set_server'"
  350. cursor.execute(sql_character_set_server)
  351. data = cursor.fetchone()
  352. character_set_server = data[1]
  353. print "character_set_server: %s" % character_set_server
  354. #21.time_zone
  355. sql_time_zone = "show global variables like 'time_zone'"
  356. cursor.execute(sql_time_zone)
  357. data = cursor.fetchone()
  358. time_zone = data[1]
  359. print "time_zone: %s" % time_zone
  360. #22.default_storage_engine
  361. sql_default_storage_engine = "show global variables like 'default_storage_engine'"
  362. cursor.execute(sql_default_storage_engine)
  363. data = cursor.fetchone()
  364. default_storage_engine = data[1]
  365. print "default_storage_engine: %s" % default_storage_engine
  366. print '''
  367. ----------------------------------------------------------------------------------------------------------------
  368. start status check
  369. 1.opened files
  370. 2.Opened_table_definitions
  371. 3.opened tables
  372. 4.max_used_connections
  373. ----------------------------------------------------------------------------------------------------------------
  374. '''
  375. #1.opened files
  376. sql_Opened_files = "show global status like 'Opened_files'"
  377. cursor.execute(sql_Opened_files)
  378. data = cursor.fetchone()
  379. Opened_files = data[1]
  380. print "Opened_files: %s" % Opened_files
  381. #2.Opened_table_definitions files
  382. sql_Opened_table_definitions = "show global status like 'Opened_table_definitions'"
  383. cursor.execute(sql_Opened_table_definitions)
  384. data = cursor.fetchone()
  385. Opened_table_definitions = data[1]
  386. print "Opened_table_definitions: %s" % Opened_table_definitions
  387. #3.Opened_tables
  388. sql_Opened_tables = "show global status like 'Opened_tables'"
  389. cursor.execute(sql_Opened_tables)
  390. data = cursor.fetchone()
  391. Opened_tables = data[1]
  392. print "Opened_tables: %s" % Opened_tables
  393. #4.Max_used_connections
  394. sql_Max_used_connections = "show global status like 'Max_used_connections'"
  395. cursor.execute(sql_Max_used_connections)
  396. data = cursor.fetchone()
  397. Max_used_connections = data[1]
  398. print "Max_used_connections: %s" % Max_used_connections
  399. print '''
  400. ----------------------------------------------------------------------------------------------------------------
  401. start user check
  402. 1.no name user
  403. 2.no pass user
  404. 3.any where user
  405. 4.high privileges user
  406. ----------------------------------------------------------------------------------------------------------------
  407. '''
  408. #1.no name user
  409. cursor.execute("select user,host from mysql.user where user='';")
  410. no_name_user = cursor.fetchall()
  411. print "\033[1;33;44m 1: result of no name users\033[0m"
  412. if no_name_user:
  413. for user in no_name_user:
  414. username = user[0]
  415. host = user[1]
  416. print " user_name: %-20s host: %-20s" % \
  417. (username, host)
  418. else:
  419. print "all users have name"
  420. #2.no pass user
  421. cursor.execute("select user,host from mysql.user where authentication_string='';")
  422. no_pass_user = cursor.fetchall()
  423. print "\033[1;33;44m 1: result of no pass users\033[0m"
  424. if no_pass_user:
  425. for user in no_pass_user:
  426. username = user[0]
  427. host = user[1]
  428. print " user_name: %-20s host: %-20s" % \
  429. (username, host)
  430. else:
  431. print "all users have password"
  432. #3.any where user
  433. cursor.execute("select user,host from mysql.user where host='%';")
  434. anywhere_user = cursor.fetchall()
  435. print "\033[1;33;44m 3: result of % users\033[0m"
  436. if anywhere_user:
  437. for user in anywhere_user:
  438. username = user[0]
  439. host = user[1]
  440. print " user_name: %-20s host: %-20s" % \
  441. (username, host)
  442. else:
  443. print "no % user"
  444. #4.high privileges user
  445. cursor.execute("select user,host from mysql.user where user not in ('mysql.session','mysql.sys');")
  446. mysql_user = cursor.fetchall()
  447. print "\033[1;33;44m 3: result of % users\033[0m"
  448. if mysql_user:
  449. for user in mysql_user:
  450. username = user[0]
  451. host = user[1]
  452. user_sql = "show grants for %s@'%s';" % (username, host)
  453. cursor.execute(user_sql)
  454. priv = []
  455. for i in cursor:
  456. priv.append(tuple(re.split(r' TO ', str(*i))[0].split(r' ON ')))
  457. print "username: %s priv: %s" % (username, priv)
  458. else:
  459. print "no % user"

效果图:

  1. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. ++ MySQL Check report ++
  3. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4. start time: 2018-06-29 10:24:47.129608
  5. ----------------------------------------------------------------------------------------------------------------
  6. start table check
  7. 1.size
  8. 2.much indexes
  9. 3.fragment
  10. 4.rows
  11. 5.charset
  12. 6.big column
  13. 7.long column
  14. 8.no indexes
  15. ----------------------------------------------------------------------------------------------------------------
  16. 1: result of table is more than 10G
  17. no table is more than 10G
  18. 2: result of table more than 6 indexes
  19. no table has more than 6 indexes
  20. 3: result of table has big fragment
  21. no table has big fragment
  22. 4: result of table has more than 20000000 rows
  23. no table has has more than 20000000 rows
  24. 5: result of table is not in default charset
  25. table_schema: test table_name : test charset: latin1_swedish_ci
  26. 6: result of table has big columns
  27. table_schema: test table_name : test column_name: content data_type: blob
  28. 7: result of table has long columns
  29. table_schema: test table_name : test column_name: name data_type: varchar length: 1024
  30. 8: result of table has not indexes
  31. table_schema: test table_name : test1
  32. table_schema: test table_name : test2
  33. ----------------------------------------------------------------------------------------------------------------
  34. start index check
  35. 1.redundant indexes
  36. 2.to much columns indexes
  37. 3.unused indexes
  38. ----------------------------------------------------------------------------------------------------------------
  39. 1: result of redundant indexes
  40. table_schema: test table_name: test2 index_name: idx_id column_name:id
  41. 2: result of to much columns indexes
  42. all index have column under 5
  43. 3: result of redundant indexes
  44. table_schema: test table_name: test2 index_name: idx_test
  45. table_schema: test table_name: test2 index_name: idx_id
  46. ----------------------------------------------------------------------------------------------------------------
  47. start variables check
  48. 1.version
  49. 2.innodb_buffer_pool_size
  50. 3.innodb_flush_log_at_trx_commit
  51. 4.innodb_log_file_size
  52. 5.innodb_log_files_in_group
  53. 6.innodb_file_per_table
  54. 7.innodb_open_files
  55. 8.innodb_data_home_dir
  56. 9.innodb_flush_method
  57. 10.innodb_max_dirty_pages_pct
  58. 11.sync_binlog
  59. 12.max_connections
  60. 13.query_cache_type
  61. 14.sort_buffer_size
  62. 15.read_buffer_size
  63. 16.max_allowed_packet
  64. 17.table_open_cache
  65. 18.thread_cache_size
  66. 19.key_buffer_size
  67. 20.charset
  68. 21.time_zone
  69. 22.default storage engine
  70. ----------------------------------------------------------------------------------------------------------------
  71. mysql_version: 5.7.20-log
  72. innodb_buffer_pool_size: 1024.000000 M
  73. innodb_flush_log_at_trx_commit: 2
  74. innodb_log_file_size: 100 M
  75. innodb_log_files_in_group: 3
  76. innodb_file_per_table: ON
  77. innodb_open_files: 2048
  78. innodb_data_home_dir: /storage/mysql/data/
  79. innodb_flush_method: O_DIRECT
  80. innodb_max_dirty_pages_pct: 50.000000
  81. sync_binlog: 0
  82. max_connections: 100
  83. query_cache_type: OFF
  84. sort_buffer_size: 0.125000 M
  85. read_buffer_size: 2.000000 M
  86. max_allowed_packet: 4.000000 M
  87. table_open_cache: 2048
  88. thread_cache_size: 200
  89. key_buffer_size: 8.000000 M
  90. character_set_server: utf8
  91. time_zone: SYSTEM
  92. default_storage_engine: InnoDB
  93. ----------------------------------------------------------------------------------------------------------------
  94. start status check
  95. 1.opened files
  96. 2.Opened_table_definitions
  97. 3.opened tables
  98. 4.max_used_connections
  99. ----------------------------------------------------------------------------------------------------------------
  100. Opened_files: 566
  101. Opened_table_definitions: 225
  102. Opened_tables: 1855
  103. Max_used_connections: 2
  104. ----------------------------------------------------------------------------------------------------------------
  105. start user check
  106. 1.no name user
  107. 2.no pass user
  108. 3.any where user
  109. 4.high privileges user
  110. ----------------------------------------------------------------------------------------------------------------
  111. 1: result of no name users
  112. all users have name
  113. 2: result of no pass users
  114. user_name: test host: %
  115. 3: result of % users
  116. user_name: jumpprog host: %
  117. user_name: test host: %
  118. user_name: test1 host: %
  119. 4: result of user privileges
  120. username: jumpprog priv: [('GRANT USAGE', '*.*'), ('GRANT ALL PRIVILEGES', '`jumpmysql`.*')]
  121. username: test priv: [('GRANT ALL PRIVILEGES', '*.*')]
  122. username: test1 priv: [('GRANT USAGE', '*.*'), ('GRANT ALL PRIVILEGES', '`test`.*')]
  123. username: root priv: [('GRANT ALL PRIVILEGES', '*.*'), ('GRANT PROXY', "''@''")]