6

Moving a MySQL database from Windows to Linux I have the problem that on Linux the names of the tables are case sensitive. This is a problem, because the Java application that I am developing can't find tables.

I have changed my /etc/mysql/my.cnf file adding the row:

lower_case_table_names=1

But that did not change anything.

My server version is: 5.1.61-0ubuntu0.11.10.1 (Ubuntu)

How can I configure MySQL to ignore case in table names?

asked Apr 7, 2012 at 9:51
2
  • I find the most sounding solution to this issue is to write all table names case-sensitive in the code! Commented Feb 22, 2015 at 10:27
  • @Neveroldmilk that would be nonstandard: future developers expect that sql in not case sensitive. Commented Feb 23, 2015 at 15:09

2 Answers 2

6

Just altering the lower_case_table_names setting isn't enough. It needs to be done before you import your database(s).

The MySQL 5.1 documentation lists a procedure for moving between Windows and Linux/UNIX. This will ensure that your desired rules for enforcing case sensitivity are followed. Take a look and verify that you did these steps in the correct order:

To convert one or more entire databases, dump them before setting lower_case_table_names, then drop the databases, and reload them after setting lower_case_table_names:

1 - Use mysqldump to dump each database:

mysqldump --databases db1> db1.sql

mysqldump --databases db2> db2.sql

... Do this for each database that must be recreated.

2 - Use DROP DATABASE to drop each database.

3 - Stop the server, set lower_case_table_names in the [mysqld] section of your \etc\mysql\my.cnf file, and restart the server.

4 - Reload the dump file for each database. Because lower_case_table_names is set, each database and table name will be converted to lowercase as it is recreated:

mysql < db1.sql

mysql < db2.sql

Vitaly Olegovitch
1901 gold badge1 silver badge7 bronze badges
answered Apr 7, 2012 at 10:21
1
  • Does mysqldump do a perfect dump? Will any of the data change if we export-drop-import? Commented Apr 9, 2015 at 19:24
-1

File in etc/my.cnf Find this # The MySQL server [mysqld] and set lower_case_table_names = 1

There is no need to drop db. It works so first check with this. Reason is default value of lower_case_table_names =1 for Windows.

answered Jun 29, 2016 at 5:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.