问题
Table ‘zup.Domain_System’ doesn’t exist
### The error occurred while setting parameters ### SQL: SELECT * FROM Domain_System WHERE domain = ? LIMIT 1 ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'zup.Domain_System' doesn't exist ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'zup.Domain_System' doesn't exist] with root cause
解决问题
首先可以肯定我数据库中是存在这个表的,只是全是小写的,而SpringBoot项目中的是开头大写字母的
在mysql 5.7.x版本中默认是大小写区分的。
可以登录mysql之后查看show variables like "%case%";
:
lower_case_table_names=0,默认为0,则区分大小写
truedei@truedei:/codeProject$ sudo mysql -h 127.0.0.1 -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.29 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> show variables like "%case%"; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_file_system | OFF | | lower_case_table_names | 0 | +------------------------+-------+ 2 rows in set (0.00 sec) MySQL [(none)]>
所以解决方法就是修改mysql中的配置文件,让其忽略大小写:
因为我使用的是docker安装的mysql5.7,并且把配置文件映射到 了:/data/mysql/conf/my.conf
修改配置文件my.conf
truedei@truedei:~$ truedei@truedei:~$ sudo vim /data/mysql/conf/my.conf
添加上:
lower_case_table_names=1
保存
我在这里就需要重启docker,你如果是直接安装的mysql,可以直接重新mysql即可
truedei@truedei:~$ truedei@truedei:~$ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0a122a08125f mysql:5.7.29 "docker-entrypoint.s…" 2 hours ago Up 4 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysql57 truedei@truedei:~$ truedei@truedei:~$ truedei@truedei:~$ truedei@truedei:~$ sudo docker restart mysql57 mysql57 truedei@truedei:~$
可以看到变成了1
truedei@truedei:/codeProject$ sudo mysql -h 127.0.0.1 -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.29 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> MySQL [(none)]> show variables like "%case%"; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_file_system | OFF | | lower_case_table_names | 1 | +------------------------+-------+ 2 rows in set (0.00 sec) MySQL [(none)]>
就可以解决此问题