问题
Good day stack overflow.
I am having problems on importing an sql file to my windows machine. The sql file is from a linux machine. What happens is that the table names from linux are camel cased and when migrated to windows, all becomes lower cased. I don't want to adjust my codes to be able to access my database so is there anyway that I could achieve the camel-cased table names in windows?
Many thanks.
From linux table names: -> FooBar
When it is imported to mysql workbench in windows: -> foobar
the query looks like this:
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"
回答1:
There is a difference between Linux and Windows on how both operating systems store the table names (allowing lower case only or not). This can be controlled by the lower_case_table_names
system variable. Your Windows installation, probably has this value set to 1 and your Linux server had this value set as 0. Following the "Identifier Case Sensitivity" part of the User Manual, you have two options:
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.
or
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.
Some links:
- lower_case_table_names System Variable
- Identifier Case Sensitivity
来源:https://stackoverflow.com/questions/13225379/mysql-dump-from-linux-to-windows