mysql lower case_mysql lower-case-table-names参数

线上有业务用到开源的产品,其中SQL语句是大小写混合的,而建表语句都是小写的,mysql默认设置导致这些执行失败。

就需要设置忽略大小写。设置lower-case-table-names=1,重启mysql实例生效。

这时就产生了另外一个问题,之前的大写字母的数据库名都失效了。都提示找不到数据库名。注释掉个lower-case-table-names=1.

则没有这个问题,因此这个问题肯定是lower-case-table-names参数引起的。故查找了官方解释:

Mysql官方文档的介绍:

Value

Meaning

0

Table and database names are stored on disk using the lettercase

specified in the CREATE TABLE orCREATE DATABASE statement.

Name comparisons are case sensitive. You shouldnotset

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). If you force this

variable to 0 with --lower-case-table-names=0 on

a case-insensitive file system and accessMyISAMtablenames using different lettercases, index corruption

may result.

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.

2

Table and database names are stored on disk using the lettercase

specified in the CREATE TABLE orCREATE DATABASE statement,

but MySQL converts them to lowercase on lookup. Name comparisons are not case

sensitive. This worksonlyon file systems that are not case sensitive!InnoDBtable names are

stored in lowercase, as forlower_case_table_names=1.

默认为0,大小写敏感。

设置1,大小写不敏感。创建的表,数据库都是以小写形式存放在磁盘上,对于sql语句都是转换为小写对表和DB进行查找。

设置2,创建的表和DB依据语句上格式存放,凡是查找都是转换为小写进行。

If you plan to set thesystem

variable to 1 on Unix, you must first convert your old database and table names

to lowercase before stoppingand

restarting it with the new variable setting. To do this for an individual

table, use

当想设置

官方文档的解释。要开启

所以要想忽略大小写,还需要提前将大写数据库名更改小写,否则报错。数据库名无法rename.可以新建一个小写的数据库名。

然后rename table 到新的数据库,完成表的迁移。

在进行数据库参数设置之前,需要掌握这个参数带来的影响,切不可盲目设置。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值