不废话,直入主题
忽略数据表大小写
- 安装完成之后编辑配置文件
vim /etc/my.cnf
- 输入以下内容
> [mysqld]
> lower_case_table_names=1
- 重启MySQL
systemctl restart mysqld.service
- 验证大小写敏感是否已配置
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
至此,完成大小写敏感配置