收集统计信息
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}"

浙公网安备 33010602011771号