lower_case_table_names参数设置解决Error Code: 1146. Table doesn't exist?
检查程式代码发现执行SQL :SELECT * FROMBase_User ... 报的错,但检查Mysql5.7.16for Linux 中table却存在。
尝试把SQL中驼峰式表名(Base_User)改为全小写表名SELECT * FROMbase_user可以正常执行,原来是因为Mysql forLinux中默认大小敏感,而windows中默认大小写不敏感。
在my.cnf设置参数 lower_case_table_names 为1,并重启mysql后大小写不敏感
[mysqld]
lower_case_table_names=1
参考文档:
lower_case_table_names
If set to 0, table names are stored as specified and comparisons are case-sensitive.
If set to 1, table names are stored in lowercase on disk and comparisons are not case sensitive.
If set to 2, table names are stored as given but compared in lowercase. This option also applies to database names and table aliases.
On Windows the default value is 1. On OS X, the default value is 2.
You shouldnotsetlower_case_table_namesto 0 if you are running MySQL on a system where the data directory resides on a case-insensitive file system (such as on Windows or OS X).
It is an unsupported combination that could result in a hang condition when running anINSERT INTO ... SELECT ... FROMtbl_nameoperation with the wrongtbl_nameletter case. WithMyISAM, accessing table names using different letter cases could cause index corruption.
As of MySQL 5.7.9, an error message is printed and the server exits if you attempt to start the server with--lower_case_table_names=0on a case-insensitive file system.
If you are usingInnoDBtables, you should set this variable to 1 on all platforms to force names to be converted to lowercase.
The setting of this variable in MySQL 5.7 affects the behavior of replication filtering options with regard to case sensitivity.
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。