您的位置:首页 > 数据库 > MySQL

MySQL表名不区分大小写的设置方法

2017-06-02 17:25 381 查看
 Linux下的MySQL默认是区分表名大小写的,通过如下设置,可以让MySQL不区分表名大小写:

1、用root登录,修改 /etc/my.cnf;

2、在[mysqld]节点下,加入一行: lower_case_table_names=1



一定要是在在[mysqld]节点下不然不会生效。下面还有其他的节点不做详细说明。

附上文件所有内容:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
lower_case_table_names=1
max_allowed_packet = 20M

#skip-grant-tables
slow_query_log=TRUE
slow_query_log_file=/home/mysql02/mysql/logs/slow_query_log.txt
long_query_time=5

# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
max_connections=1000
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d


3、重启MySQL即可;

其中 lower_case_table_names=1 参数缺省地在 Windows 中这个选项为 1 ,在 Unix 中为 0,因此在window中不会遇到的问题,一旦一直到linux就会出问题的原因(尤其在mysql对表起名时是无法用大写字母的,而查询用了大写字母却会出查不到的错误,真是弄的莫名其妙)

原文链接:http://www.jb51.net/article/49249.htm

如有遗漏欢迎在评论区留言。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: