Monday, December 22, 2008

Solving Table Name Case Sensitive Problem of Mysql on Linux

Table name case sensitivity issue is a common problem to hit when you are trying to port an application to use Mysql on Linux. You can set the Mysql to always store table name in lower case by setting the startup parameter lower_case_table_names=1.

You can type the following to check if the parameter is set or not:-

mysqladmin -u root -p variables


If it is not set, you can set it by editing /etc/mysql/my.cnf:

sudo gedit /etc/mysql/my.cnf

In my.cnf, it should have portions like this:-

[mysqld]
#
# * Basic Settings
#

#
# * IMPORTANT
# If you make changes to these settings and your system uses apparmor, you may
# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#

lower_case_table_names=1

user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking


Then, restart the server:-

mysqladmin -u root -p shutdown
sudo mysqld

2 comments:

  1. On a related note, you might find this post interesting: http://www.alberton.info/dbms_identifiers_and_case_sensitivity.html

    ReplyDelete
  2. Hi quipo,

    That's a very informative page, thanks for referencing. :D

    ReplyDelete