Configure MySQL to handle camel case (or case sensitive) table names

The default settings provided with the Win32 and Win64 builds of MySQL enforce a strict lowercase conversion for all the table and database names. This feature can be annoying for those working with auto-generated code tools (such as Entity Framework) because all the entities will be created in lower case as well. To overcome that we can use a useful, yet not widely known MySQL system variable who allows us to change the default behavior: . It can easily be added to the MySQL my.cfg file, usually found in the following folder:
The system variable must be placed under the [mysqld] section, just like that:
Possible values are:

  • 0: Table and database names are stored on disk using the lettercase specified in the or  statement. Name comparisons are case sensitive. It’s not advisable to set this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or Mac OS X): the official documentation discourages that because there could be issues with MyISAM indexes files.
  • 1: Table names are stored in lowercase on disk and name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases. This means that all queries will be case-insensitive regarding db and/or table names (SELECT * FROM STUDENTS e SELECT * FROM students will give the exact same result); on the other side we won’t be able to use uppercase characters at all, which bring us back to our main issue.
  • 2: Table and database names are stored on disk using the lettercase specified in the or  statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This works only on file systems that are not case sensitive! table names are stored in lowercase, as for .
For an extensive overview of the system variables we suggest to check out the official MySQL documentation:
RELATED POSTS

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies.

View all posts by Ryan