MySQL调整配置:不区分大小写
一、问题
首先抛出问题,遇到了在windows本机上安装的MySQL可以不区分大小写,而Linux主机上安装的MySQL区分大小写导致运行程序报错
022-04-22 14:00:29.608 [QuartzScheduler_MyScheduler-LAPTOP-CMIE3UE91650607199221_ClusterManager] ERROR druid.sql.Statement:149 - {conn-10004, pstmt-20009} execute error. SELECT * FROM QRTZ_LOCKS WHERE SCHED_NAME = 'MyScheduler' AND LOCK_NAME = ? FOR UPDATE
java.sql.SQLSyntaxErrorException: Table 'jeecg-boot.QRTZ_LOCKS' doesn't exist
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
错误提示,没有找到jeecg-boot.QRTZ_LOCKS这个表,我检查了一下。是存在jeecg-boot.qrtz_locks这个表的。那么问题就显而易见了,因为区分大小写导致的
Windows下MySQL
Linux下MySQL
二、Linux解决
## 1.修改my.cnf配置文件
## 将lower_case_table_names=1添加到最后即可
[root@zxy_slave1 ~]# vim /etc/my.cnf
lower_case_table_names=1
## 2.关闭重启mysql服务
[root@zxy_slave1 ~]# systemctl stop mysqld
[root@zxy_slave1 ~]# systemctl start mysqld
[root@zxy_slave1 ~]# mysql -uroot -p[输入密码]
## 3.再次验证
mysql> select * from `QRTZ_LOCKS`;
+-------------+----------------+
| SCHED_NAME | LOCK_NAME |
+-------------+----------------+
| MyScheduler | STATE_ACCESS |
| MyScheduler | TRIGGER_ACCESS |
+-------------+----------------+
2 rows in set (0.01 sec)