mysql数据库中的表不存在,可以查看的问题

时间:2021-07-25 06:24:51

先说说起因吧,我在使用super-diamond的时候发现创建项目的时候不成功,到后台查看日志之后发现是Table 'edu_diamond.conf_user' doesn't exist于是乎打开navcat发现表都是在的呀。这就很奇怪了,后来查询资料知道原来linux下默认的表名是区分大小的。

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'edu_diamond.conf_user' doesn't exist
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_76]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_76]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_76]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_76]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:408) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.Util.getInstance(Util.java:383) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1062) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2840) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082) ~[mysql-connector-java-5.1.31.jar:na]
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2212) ~[mysql-connector-java-5.1.31.jar:na]
    at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2714) ~[druid-1.0.7.jar:1.0.7]
    at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeQuery(FilterEventAdapter.java:465) ~[druid-1.0.7.jar:1.0.7]
    at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2711) ~[druid-1.0.7.jar:1.0.7]
    at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeQuery(PreparedStatementProxyImpl.java:132) ~[druid-1.0.7.jar:1.0.7]
    at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:227) ~[druid-1.0.7.jar:1.0.7]
    at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:646) ~[spring-jdbc-3.2.12.RELEASE.jar:3.2.12.RELEASE]
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589) ~[spring-jdbc-3.2.12.RELEASE.jar:3.2.12.RELEASE]
    ... 51 common frames omitted

1、查看问题

show VARIABLES LIKE '%case%'

mysql数据库中的表不存在,可以查看的问题

lower_case_table_names是0说明是区分大小的

2、解决问题

找到mysql的配置文件/etc/my.cnf在[mysqld]下增加

lower_case_table_names=1
service mysqld restart
Stopping mysqld:                                           [ OK ]
Starting mysqld:                                             [ OK ]

再试试发现居然还是不行,还是报Table 'edu_diamond.conf_user' doesn't exist

3、解决问题

想了想反正没招了,那我把数据库删掉从新建总可以了吧,嘿,我还没想到现在删数据库都不让我删了Error dropping database (can't rmdir './edu_diamond', errno: 39)好惆怅啊
还是去找老外,google了下,找到下面这篇文章
可以去看看这个MySQL: Error dropping database (errno 13; errno 17; errno 39)
mysql数据库中的表不存在,可以查看的问题
还是老外靠谱呀,一个老外说到是mysql的bug,找到问题了就好办了

  1. lower_case_table_names改0重启mysql
  2. 备份数据库edu_diamond
  3. 删除数据库edu_diamond
  4. lower_case_table_names改1重启mysql
  5. 恢复数据库edu_diamond
  6. 完美解决