收集统计信息

vi a.sh

!/bin/bash

user=oper_dc
password=operzADF2020qewr
host=172.20.47.78
port=3307
analyze_file=analyze.sql
mysql -u${user} -p${password} -h${host} -P${port} -NBe "SELECT concat('ANALYZE table `',table_schema,'`.`',table_name,'`;') from information_schema.`TABLES` WHERE table_schema not in ('mysql','information_schema','sys','performance_schema');">${analyze_file}
mysql -u${user} -p${password} -h${host} -P${port} -e "source ${analyze_file}"

posted @ 2025-02-28 17:39  ocmji  阅读(24)  评论(0)    收藏  举报