目前我们使用阿里云的云数据库RDS-MySQL数据库默认设置都是不区分大小写的,为了保证自建MySQL与阿里云RDS保持配置一致,该如何设置Mysql不区大小写呢,通过修改Mysql配置文件my.cnf方式即可实现,操作方法如下:

vi /etc/my.cnf

在最后一行添加以下内容,并保存退出。

lower_case_table_names=1

修改后my.cnf配置如下

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

lower_case_table_names=1

最后重启mysql即可生效:

systemctl restart mysqld
上一篇 下一篇