这是因为您使用的文件系统。这被解释为
In MySQL, databases correspond to directories within the data directory.
Each table within a database corresponds to at least one file within the database directory (and possibly more, depending on the storage engine).
Triggers also correspond to files. Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database, table, and trigger names.
This means such names are not case-sensitive in Windows, but are case-sensitive in most varieties of Unix.
One notable exception is macOS, which is Unix-based but uses a default file system type (HFS+) that is not case-sensitive.
However, macOS also supports UFS volumes, which are case-sensitive just as on any Unix.
您可以在 mysql 官方网站上阅读更多内容
您必须通过运行以下查询来检查区分大小写,以了解数据库的区分大小写:
SHOW VARIABLES LIKE "lower_case_table_names";
值 0(Linux 上的默认值)表示名称比较区分大小写,值 1(Windows 上的默认值)表示不区分大小写,而值 2(macOS 上的默认值)也可以视为不区分大小写。
现在,如果查询结果为 0,那么您需要更改 lower_case_table_names
变量以使您的数据库不区分大小写。
请记住备份您的数据库,因为更改此变量的值后,您的数据库可能表现不佳。您可以恢复数据库后使其不区分大小写。使用以下命令备份您的数据库(并应在备份后将其删除):
mysqldump -u username -p db_name > dump.sql
现在,您需要找到您的 mysql 配置文件。配置文件可能在
/etc/mysql/my.cnf
或
/etc/mysql/mysql.conf.d/mysqld.cnf
您需要查找 [mysqld],无论您找到哪个文件的详细信息,例如(其中一个):
[mysqld]
user = mysql
pid-file = /***
socket = /***
port = ****
basedir = /***
datadir = /***
tmpdir = /tmp
lc-messages-dir = /****
编辑您的文件:
vi /etc/mysql/mysql.conf.d/mysqld.cnf
并粘贴lower_case_table_names=1
下面的行 [mysqld]
您需要重新启动mysql:
sudo service mysql restart
您现在可以使用以下命令恢复数据库:
mysql -u username -p db_name < dump.sql
完毕。干杯。