Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maintain case sensitivity when importing db into windows

I have an export from a MYSQL database on a linux machine however when importing that database into MYSQL on windows all of the table names that were camel cased are now all lower case. The sql dump has the correct case in it but the importing via phpmyadmin seams to remove these.

How can I import it and keep the case?

like image 533
user103219 Avatar asked May 19 '10 23:05

user103219


People also ask

How do I make MySQL case sensitive in Windows?

For windows, it's available in the C:\ProgramData\MySQL\MySQL Server X.X directory. Open this file in administrator mode and set the lower_case_table_names variable value to 2. These changes will not take effect until you restart the MySQL server before restarting the MySQL Server by following steps.

Is MySQL case sensitive by default?

By default, it depends on the operating system and its case sensitivity. This means MySQL is case-insensitive in Windows and macOS, while it is case-sensitive in most Linux systems. However, you can change the behavior by changing collation.

How do I make MySQL database case sensitive?

To set the collation for the entire database, you can use: CREATE DATABASE test_database CHARACTER SET utf8 COLLATE utf8_general_cs; You can also change the collation on an existing database via ALTER DATABASE. (For more information see the MySQL Database Character Set and Collation manual entry.)

Are Windows Shares case sensitive?

The Windows file system supports setting case sensitivity with attribute flags per directory. While the standard behavior is to be case-insensitive, you can assign an attribute flag to make a directory case sensitive, so that it will recognize Linux files and folders that may differ only by case.


2 Answers

There is a setting for mysql to allow case differentiation in windows. You need to edit the my.cnf file and alter the setting:

lower_case_table_names=2

Then restart mysql.

Otherwise, this may be a case of phpmyadmin changing case in the way it passes queries to the server rather than a linux-to-windows problem. Have you tried importing the sql dump using another mysql manager such as SQLyog? (Tools -> Restore from SQL Dump...)

like image 135
JYelton Avatar answered Sep 23 '22 22:09

JYelton


It is probably worth reading the following page from the MySQL Reference Manual: http://dev.mysql.com/doc/refman/5.5/en/identifier-case-sensitivity.html

Based on that, I think you need to set to 0, not 2, which will ensure that the schema is stored using the same case as defined in your DDL.

lower_case_table_names=0
like image 20
Atonewell Avatar answered Sep 21 '22 22:09

Atonewell