Mysql 设置表名不区分大小写

1、找到Mysql的配置文件

#vim /etc/my.cnf

在[mysqld]下面添加

lower_case_table_names=1

其中等于0时是区分大小写的

[client]
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]
# 一般配置选项 
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data
port=3306
character-set-server=utf8mb4
explicit_defaults_for_timestamp=true
character-set-client-handshake = FALSE 
collation-server = utf8mb4_unicode_ci 
init_connect='SET NAMES utf8mb4'

sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

#socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# 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
# 表名不区分大小写,等于0时是区分大小写的
lower_case_table_names=1

[mysqld_safe]
#log-error=/var/log/mysql/mysqld.log
#pid-file=/var/run/mysql/mysql.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

2、重启Mysql

# service mysql restart

重启的时候可能会出现

Redirecting to /bin/systemctl restart mysql.service

Failed to restart mysqld.service: Unit not found.

这时候需要给MySQL的安装目录添加权限

# chown -R mysql:mysql /usr/local/mysql

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页