这个脚本可以根据服务器内存大小来修改/etc/my.cnf配置文件
如果要使用,请根据你自己配置文件情况修改后运行

Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ]; then
sed -i 's/table_open_cache = 128/table_open_cache = 256/g' /etc/my.cnf
sed -i 's/tmp_table_size = 16M/tmp_table_size = 32M/g' /etc/my.cnf
sed -i 's/thread_cache_size = 8/thread_cache_size = 16/g' /etc/my.cnf
sed -i 's/query_cache_size = 8M/query_cache_size = 16M/g' /etc/my.cnf
sed -i 's/innodb_buffer_pool_size = 64M/innodb_buffer_pool_size = 128M/g' /etc/my.cnf
sed -i 's/myisam_sort_buffer_size = 8M/myisam_sort_buffer_size = 16M/g' /etc/my.cnf
sed -i 's/key_buffer_size = 8M/key_buffer_size = 16M/g' /etc/my.cnf
elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ]; then
sed -i 's/table_open_cache = 128/table_open_cache = 512/g' /etc/my.cnf
sed -i 's/tmp_table_size = 16M/tmp_table_size = 64M/g' /etc/my.cnf
sed -i 's/thread_cache_size = 8/thread_cache_size = 32/g' /etc/my.cnf
sed -i 's/query_cache_size = 8M/query_cache_size = 32M/g' /etc/my.cnf
sed -i 's/innodb_buffer_pool_size = 64M/innodb_buffer_pool_size = 512M/g' /etc/my.cnf
sed -i 's/myisam_sort_buffer_size = 8M/myisam_sort_buffer_size = 32M/g' /etc/my.cnf
sed -i 's/key_buffer_size = 8M/key_buffer_size = 64M/g' /etc/my.cnf
elif [ $Memtatol -gt 3500 ];then
sed -i 's/table_open_cache = 128/table_open_cache = 1024/g' /etc/my.cnf
sed -i 's/tmp_table_size = 16M/tmp_table_size = 128M/g' /etc/my.cnf
sed -i 's/thread_cache_size = 8/thread_cache_size = 64/g' /etc/my.cnf
sed -i 's/query_cache_size = 8M/query_cache_size = 64M/g' /etc/my.cnf
sed -i 's/innodb_buffer_pool_size = 64M/innodb_buffer_pool_size = 1024M/g' /etc/my.cnf
sed -i 's/myisam_sort_buffer_size = 8M/myisam_sort_buffer_size = 64M/g' /etc/my.cnf
sed -i 's/key_buffer_size = 8M/key_buffer_size = 256M/g' /etc/my.cnf
fi