Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force case sensitive table names?

I'm working on a MySQL database in windows.

I must move it into a Linux environment. MySQL database contains a lot of tables and stored procedures which are CASE SENSITIVE.

When I backup my database, all table names are forced lowercase so when I restore it in Linux it complains because you can't make duplicate tables and stored procedures.

I don't have access to the MySQL configuration in the linux environment so I cant change MySQL settings to case insensitive mode.

Is there any way to force MySQL (v5.x) to use case sensitive table names in windows?

like image 458
Ehsan Khodarahmi Avatar asked Jun 06 '11 07:06

Ehsan Khodarahmi


People also ask

How do I change case sensitivity in MySQL?

Stop the server, set lower_case_table_names , and restart the server. Reload the dump file for each database. Because lower_case_table_names is set, each database and table name is converted to lowercase as it is recreated: mysql < db1.

Is table name case-sensitive in SQL Server?

SQL Server is a case-sensitive back-end application. This means that a table named "addr" is distinguished from a table named "ADDR." However, because Microsoft Query is an MS-DOS-based application, it is unable to distinguish cases; therefore, Microsoft Query views "addr" and "ADDR" as the same file.

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.

Are MySQL column names case-sensitive?

Field (column) names are case-insensitive regardless. EDIT: we're talking about the operating system on the MySQL server machine, not client.


2 Answers

Read the following chapter in the official MySQL documentation: Identifier Case Sensitivity.

Then add the following system variable to the server section, [mysqld], inside the my.ini configuration file and restart the MySQL service:

lower_case_table_names=2

like image 56
ATorras Avatar answered Sep 28 '22 14:09

ATorras


Have a look at this article - http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html

Mode 2 allows to store tables with specified lettercase, but anyway, name comparisons won't be case sensitive and you won't be able to store table1 and Table1 at the same time.

like image 45
Devart Avatar answered Sep 28 '22 15:09

Devart