spring 后台报错(代码取消高亮以避免登录后复制)
com.mysql.cj.core.exceptions.CJException: Unknown system variable ‘query_cache_size’
MySQL连接器发送“SHOW variables”,然后解析结果以相应地“配置”连接器。
在类中,MysqlaSession.loadServerVariables()是决定应该包含哪些变量以及不包含哪些变量的方法。
该过程有点粗鲁和基本,具有一系列IF条件检查服务器版本。
最后,在第 1044 行,我发现了连接器出现故障的原因:
***if (versionMeetsMinimum(8, 0, 3)) {
queryBuf.append(“, @@have_query_cache AS have_query_cache”);
} else {
queryBuf.append(“, @@query_cache_size AS query_cache_size”);
queryBuf.append(“, @@query_cache_type AS query_cache_type”);
}***
因此,如果msyql版本至少为 8.0.3,请检查变量have_query_cache,否则读取query_cache_size和query_cache_type。
在proxysql 1.4.6版本中,ProxySQL默认将自身声明为:
Server version: 5.5.30 (ProxySQL)
解决方法:
登录proxysql的管理控制台,对版本进行更新
update global_variables set variable_value=“8.0.4 (ProxySQL)” where variable_name=‘mysql-server_version’;
load mysql variables to run;save mysql variables to disk;
同时须保证proxy配置文件中的server_version版本正确



