Are table names in MySQL case sensitive?
On my Windows dev machine the code I have is able to query my tables which appear to be all lowercase. When I deploy to the test server in our datacenter the table names appear to start with an uppercase letter.
The servers we use are all on Ubuntu.
Database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix or Linux.
to resolve the issue set the lower_case_table_names to 1
this will make all your tables lowercase, no matter how you write them
In General:
Database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix.
One can configure how tables names are stored on the disk using the system variable
lower_case_table_names
. (in my.cnf configuration under [mysqld])Read the section: 10.2.2 Identifier Case Sensitivity for more information.
It depends upon
lower_case_table_names
system variable:There are three possible values for this:
0
- lettercase specified in theCREATE TABLE
orCREATE DATABASE
statement. Name comparisons are case sensitive.1
- Table names are stored in lowercase on disk and name comparisons are not case sensitive.2
- lettercase specified in theCREATE TABLE
orCREATE DATABASE
statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive.Documentation
Table names in MySQL are file system entries, so they are case insensitive if the underlying file system is.
Locate file at
/etc/mysql/my.cnf
Edit the file by adding the following lines:
[mysqld]
lower_case_table_names=1
sudo /etc/init.d/mysql restart
run
mysqladmin -u root -p variables | grep table
to check thatlower_case_table_names
is1
nowYou might need to re-create these tables to make it work