分享一份mysql一键优化脚本,值得收藏
环境准备
模块 - MySQLDB
模块 - sqlparse
Python版本 = 2.7.3
yum install -y MySQL-python tar -xvf sqlparse-0.2.3.tar.gz cd sqlparse-0.2.3 python setup.py build python setup.py install
1、脚本

# cat turning_sql.ini [database] server_ip = localhost db_user = turning db_pwd = fsxxx1234 db_name = fsl_prod db_port = 3306 [option] sys_parm = ON sql_plan = ON obj_stat = ON ses_status = ON sql_profile = ON
2、执行结果
执行命令如下:
# python mysql_turn.py -p tunging_sql.ini -s 'select * from t_ocs_production_management pm,t_ocs_production_lines pl where pm.org_code=pl.ascription_org_code'
3、输出内容
可以看到执行后的结果如下:




