c# 连接 mysql数据库 弹出异常 Unknown system variable 'lower_case_table_names'
visual studio 2019
c# nuget mysql.data package from oracle
when connection open
throw exception 'Unknown system variable 'lower_case_table_names'
本地mysql版本5.0.22
mysql> select version(); +---------------------+ | version() | +---------------------+ | 5.0.22-community-nt | +---------------------+ 1 row in set (0.00 sec)
在navicat 中查询
select @@lower_case_table_names;
结果
[SQL] select @@lower_case_table_names; [Err] 1193 - Unknown system variable 'lower_case_table_names'
看来是MySQL.data.dll提供的api 在使用之前需要查询MySQL设置lower_case_table_names,但是找不到,因此引起异常
【解决1】
在MySQL服务中加入该变量的设置
并重启
mysql> show variables;
low_priority_updates | OFF | | lower_case_file_system | OFF | | lower_case_table_names | 1 | | max_allowed_packet | 1048576 | | max_binlog_cache_size | 4294967295 | | max_binlog_size | 1073741824 |
变量存在,但是——————————》
mysql> select @@lower_case_table_names -> ; ERROR 1193 (HY000): Unknown system variable 'lower_case_table_names'
【无效】
【解决2】
升级MySQL
mysql> select version(); +------------+ | version() | +------------+ | 5.7.28-log | +------------+ 1 row in set (0.00 sec)
mysql> select @@lower_case_table_names; +--------------------------+ | @@lower_case_table_names | +--------------------------+ | 1 | +--------------------------+ 1 row in set (0.00 sec)
【问题解决!】 |