知乎专栏 | 多维度架构 |
问题分析,首先确认表是存在的,但是无法读取。可以判定是 lower_case_table_names=1 选项的问题,开启后表以小写方式打开。
Error Code: 1146. Table 'test.CACHE_UPDATE' doesn't exist
如果是 MySQL 8.0 之前没有开启 lower_case_table_names=1 ,现在需要开启,加入配置后将无法启动,解决办法是,你需要重做 mysql data 目录
[root@localhost ~]# rm -rf /var/lib/mysql/* [root@localhost ~]# systemctl restart mysqld [root@localhost ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.21 Source distribution Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like '%lower_case_table_names%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_table_names | 1 | +------------------------+-------+ 1 row in set (0.01 sec) mysql> SELECT CURRENT_SERIAL FROM CACHE_UPDATE WHERE ID=1; +----------------+ | CURRENT_SERIAL | +----------------+ | 7 | +----------------+ 1 row in set (0.00 sec)