Linux下的MySQL8大小写敏感配置

不废话,直入主题

忽略数据表大小写

  1. 安装完成之后编辑配置文件
vim /etc/my.cnf
  1. 输入以下内容
> [mysqld]
> lower_case_table_names=1
  1. 重启MySQL
systemctl restart mysqld.service
  1. 验证大小写敏感是否已配置
mysql -u root -p

输入以下内容

> show global variables like '%lower_case%';

lower_case_table_names字段值为1说明配置就完成了

验证之后有可能发现没有配置完成,这时候重启MySQL可能会出现
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
的错误,此错误表示配置出现了问题,可以查看一下详细错误信息

systemctl status mysqld.service
9月 12 20:33:01 localhost.localdomain mysqld[3480319]: 2024-09-13T00:33:01.916820Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mys>
9月 12 20:33:01 localhost.localdomain mysqld[3480319]: 2024-09-13T00:33:01.916910Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.26) starti>
9月 12 20:33:01 localhost.localdomain mysqld[3480319]: 2024-09-13T00:33:01.920133Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mys>
9月 12 20:33:01 localhost.localdomain mysqld[3480319]: 2024-09-13T00:33:01.920148Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mys>
9月 12 20:33:01 localhost.localdomain mysqld[3480319]: 2024-09-13T00:33:01.920175Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/var/lib/mysql/' >
9月 12 20:33:01 localhost.localdomain mysqld[3480319]: 2024-09-13T00:33:01.920387Z 0 [ERROR] [MY-010119] [Server] Aborting
9月 12 20:33:01 localhost.localdomain mysqld[3480319]: 2024-09-13T00:33:01.920507Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (my>
9月 12 20:33:01 localhost.localdomain systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
9月 12 20:33:01 localhost.localdomain systemd[1]: mysqld.service: Failed with result 'exit-code'.
9月 12 20:33:01 localhost.localdomain systemd[1]: Failed to start MySQL 8.0 database server.

这是无法创建测试文件导致的,创建测试文件并赋予相应权限即可

sudo mkdir -p /var/lib/mysql/
sudo chown -R mysql:mysql /var/lib/mysql/
sudo chmod -R 755 /var/lib/mysql/
sudo systemctl restart mysql

至此,完成大小写敏感配置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值