12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-11-28 13:00:22
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
[root@MySQL01 script]# vim analyze.py#!/usr/bin/env python# -*-encoding:utf8-*-#import MySQLdbimport timestep = 0db = MySQLdb.connect(host = '192.168.56.101
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
[root@MySQL01 script]# vim analyze.py
#!/usr/bin/env python
# -*-encoding:utf8-*-
#
import MySQLdb
import time
step = 0
db = MySQLdb.connect(host = '192.168.56.101',port = 3306,user = 'neo', passwd = 'neo' , db = 'information_schema')
conn = db.cursor()
sql = '''select TABLE_SCHEMA, table_name from information_schema.tables where table_schema not in ('information_schema', 'performance_schema', 'mysql') '''
# print sql
conn.execute(sql)
if conn.rowcount > 0:
for item in conn.fetchall():
sql = '''analyze table %s.%s''' % (item[0], item[1])
print sql + ' operation executes successfully!'
conn.execute(sql)
time.sleep(0.5)
conn.close()
db.close()
# 执行脚本
[root@MySQL01 script]# python2.6 analyze.py
analyze table test.area operation executes
analyze table test.class operation executes
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19