美好的一天堆栈溢出。
我在将 sql 文件导入我的 Windows 机器时遇到问题。 sql文件来自linux机器。发生的事情是来自 linux 的表名是驼峰式的,当迁移到 windows 时,全部变成小写。我不想调整我的代码来访问我的数据库,所以无论如何我可以在 Windows 中实现驼峰式表名吗?
非常感谢。
来自 linux 表名: -> FooBar
在windows中导入mysql workbench时: -> foobar
查询看起来像这样:
SELECT * FROM FooBar; // when the program is pointed to the database in windows, it will spit out that the table does not exist because the table name is "foobar"
最佳答案
Linux 和 Windows 在两种操作系统存储表名的方式上存在差异(是否只允许小写)。这可以通过 lower_case_table_names
系统变量来控制。您的 Windows 安装可能将此值设置为 1,而您的 Linux 服务器将此值设置为 0。按照用户手册的“Identifier Case Sensitivity”部分,您有两个选择:
Use
lower_case_table_names=1
on all systems. The main disadvantage with this is that when you useSHOW TABLES
orSHOW DATABASES
, you do not see the names in their original lettercase.
或
Use
lower_case_table_names=0
on Unix andlower_case_table_names=2
on Windows. This preserves the lettercase of database and table names. The disadvantage of this is that you must ensure that your statements always refer to your database and table names with the correct lettercase on Windows. If you transfer your statements to Unix, where lettercase is significant, they do not work if the lettercase is incorrect.
一些链接:
关于mysql从linux转储到windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13225379/