Debian mariadb 10.11设定表名 大小写不敏感方法

目录

[问题表现:应用中查询 表提示 表不存在](#问题表现:应用中查询 表提示 表不存在)

处理步骤:

[1、查询表名大小写敏感情况: show global variables like '%case%';](#1、查询表名大小写敏感情况: show global variables like '%case%';)

[2、修改mariadb 配置设置大小写 不敏感](#2、修改mariadb 配置设置大小写 不敏感)

[mysql 配置大小写不敏感](#mysql 配置大小写不敏感)

[mariadb 10.11设置表名大小写不敏感](#mariadb 10.11设置表名大小写不敏感)

[/etc/mysql/mariadb.conf.d/ 目录下的文件](#/etc/mysql/mariadb.conf.d/ 目录下的文件)

[总结:在mariadb 10.11以及以后的版本中,要配置表名大小写敏感问题,一般修改修改配置文件:/etc/mysql/mariadb.conf.d/50-server.cnf 在 [mysqld] 段 添加属性:lower_case_table_names=1 然后重启服务](#总结:在mariadb 10.11以及以后的版本中,要配置表名大小写敏感问题,一般修改修改配置文件:/etc/mysql/mariadb.conf.d/50-server.cnf 在 [mysqld] 段 添加属性:lower_case_table_names=1 然后重启服务)


问题表现:应用中查询 表提示 表不存在

问题处理办法: 1、先确认表存在,然后再确认数据库中表名的大小写。与mysql 一致再 mariadb中:

lower_case_file_system:表示当前系统文件是否大小写敏感(ON为不敏感,OFF为敏感),只读参数,无法修改。
lower_case_table_names:表示表名是否大小写敏感,可以修改。
lower_case_table_names = 0时,mysql会根据表名直接操作,大小写敏感
lower_case_table_names = 1时,大小写不敏感,mysql会先把表名转为小写,再执行操作。

处理步骤:

1、查询表名大小写敏感情况: show global variables like '%case%';

2、mariadb 配置设置大小写 不敏感

mariadb虽说与mysql类似,但是从mariadb 10.11开始,与mysql配置是有明显区别的(至少我这里看到是这样,具体哪个版本开始不一样,我也不知道...)

mysql 配置大小写不敏感

mysql 配置大小写不敏感操作如下:实际上以前版本的mariadb也可以这样做:

vi /etc/my.cnf 通过配置文件/etc/my.cnf下的【mysqld】添加如下内容:

|--------------------------|
| lower_case_table_names=1 |

设置好之后,重启数据库服务。

mariadb 10.11设置表名大小写不敏感

在 debian 12环境中,mariadb 10.11已经没有 /etc/my.cnf配置文件了 :

通过find / -name my.cnf 可以查询到 :

配置文件变成了:/etc/mysql/my.cnf

查看配置文件:/etc/mysql/my.cnf

可以发现内容如下:

The MariaDB configuration file

The MariaDB/MySQL tools read configuration files in the following order:

0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read.

1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,

2. "/etc/mysql/conf.d/*.cnf" to set global options.

3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.

4. "~/.my.cnf" to set user-specific options.

If the same option is defined multiple times, the last one will apply.

One can use all long options that the program supports.

Run program with --help to get a list of available options and with

--print-defaults to see which it would actually understand and use.

If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-articles/

This group is read both by the client and the server

use it for options that affect everything

client-server

Port or socket location where to connect

port = 3306

socket = /run/mysqld/mysqld.sock

mysqld

lower_case_table_names=1

Import all .cnf files from configuration directory

!includedir /etc/mysql/conf.d/

!includedir /etc/mysql/mariadb.conf.d/

关键信息:**# The MariaDB/MySQL tools read configuration files in the following order:

0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read.

1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,

2. "/etc/mysql/conf.d/*.cnf" to set global options.

3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.

4. "~/.my.cnf" to set user-specific options.**

可以看到 读取的配置文件顺序为:

1、 /etc/mysql/my.cnf、

2、/etc/mysql/mariadb.cnf、

3、/etc/mysql/conf.d/*.cnf

4、/etc/mysql/mariadb.conf.d/ 以及 ~/.my.cnf

结合说明,可以发现 以往的

mysqld

lower_case_table_names=1 在 /etc/mysql/my.cnf 是没有生效的。

查看其他配置文件:cat /etc/mysql/mariadb.cnf

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| cat /etc/mysql/mariadb.cnf # The MariaDB configuration file # # The MariaDB/MySQL tools read configuration files in the following order: # 0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read. # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults, # 2. "/etc/mysql/conf.d/*.cnf" to set global options. # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options. # 4. "~/.my.cnf" to set user-specific options. # # If the same option is defined multiple times, the last one will apply. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # # If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-articles/ # # This group is read both by the client and the server # use it for options that affect everything # [client-server] # Port or socket location where to connect port = 3306 socket = /run/mysqld/mysqld.sock [mysqld] lower_case_table_names=1 # Import all .cnf files from configuration directory !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mariadb.conf.d/ |

可以看到 在 /etc/mysql/mariadb.cnf 中设置 [mysqld]
lower_case_table_names=1 也是无效的。

查看其他配置文件:

在/etc/mysql/conf.d文件夹下有:mysql.cnf 以及 mysqldump.cnf

cat mysql.cnf

可见:mysql段的设定单独提取到了:/etc/mysql/conf.d/mysql.cnf 里:

尝试 在**/etc/mysql/conf.d/mysql.cnf**里加上 lower_case_table_names=1 :

然后重启 mariadb 服务再验证:

直接报错:mysql: unknown variable 'lower_case_table_names=1' 可见这种方式也不行。需要把配置文件 /etc/mysql/conf.d/mysql.cnf还原回来。

/etc/mysql/mariadb.conf.d/ 目录下的文件

先看一下 /etc/mysql/mariadb.conf.d/ 目录下的文件:

实在不知道 文件用处,直接cat 查看,比如,当前我使用的这个mariadb 10.11的版本

50-client.cnf文件内容:

This group is read by the client library

Use it for options that affect all clients, but not the server

client

Example of client certificate usage

#ssl-cert = /etc/mysql/client-cert.pem

#ssl-key = /etc/mysql/client-key.pem

Allow only TLS encrypted connections

#ssl-verify-server-cert = on

This group is *never* read by mysql client library, though this

/etc/mysql/mariadb.cnf.d/client.cnf file is not read by Oracle MySQL

client anyway.

If you use the same .cnf file for MySQL and MariaDB,

use it for MariaDB-only client options

client-mariadb

default-character-set=utf8mb4

50-server.cnf 文件内容如下:

These groups are read by MariaDB server.

Use it for options that only the server (but not clients) should see

this is read by the standalone daemon and embedded servers

server

this is only for the mysqld standalone daemon

mysqld

* Basic Settings

#user = mysql

pid-file = /run/mysqld/mysqld.pid

basedir = /usr

#datadir = /var/lib/mysql

#tmpdir = /tmp

Broken reverse DNS slows down connections considerably and name resolve is

safe to skip if there are no "host by domain name" access grants

#skip-name-resolve

Instead of skip-networking the default is now to listen only on

localhost which is more compatible and is not less secure.

bind-address = 127.0.0.1

* Fine Tuning

#key_buffer_size = 128M

#max_allowed_packet = 1G

#thread_stack = 192K

#thread_cache_size = 8

This replaces the startup script and checks MyISAM tables if needed

the first time they are touched

#myisam_recover_options = BACKUP

#max_connections = 100

#table_cache = 64

* Logging and Replication

Note: The configured log file or its directory need to be created

and be writable by the mysql user, e.g.:

$ sudo mkdir -m 2750 /var/log/mysql

$ sudo chown mysql /var/log/mysql

Both location gets rotated by the cronjob.

Be aware that this log type is a performance killer.

Recommend only changing this at runtime for short testing periods if needed!

#general_log_file = /var/log/mysql/mysql.log

#general_log = 1

When running under systemd, error logging goes via stdout/stderr to journald

and when running legacy init error logging goes to syslog due to

/etc/mysql/conf.d/mariadb.conf.d/50-mysqld_safe.cnf

Enable this if you want to have error logging into a separate file

#log_error = /var/log/mysql/error.log

Enable the slow query log to see queries with especially long duration

#log_slow_query_file = /var/log/mysql/mariadb-slow.log

#log_slow_query_time = 10

#log_slow_verbosity = query_plan,explain

#log-queries-not-using-indexes

#log_slow_min_examined_row_limit = 1000

The following can be used as easy to replay backup logs or for replication.

note: if you are setting up a replication slave, see README.Debian about

other settings you may need to change.

#server-id = 1

#log_bin = /var/log/mysql/mysql-bin.log

expire_logs_days = 10

#max_binlog_size = 100M

* SSL/TLS

For documentation, please read

https://mariadb.com/kb/en/securing-connections-for-client-and-server/

#ssl-ca = /etc/mysql/cacert.pem

#ssl-cert = /etc/mysql/server-cert.pem

#ssl-key = /etc/mysql/server-key.pem

#require-secure-transport = on

* Character sets

MySQL/MariaDB default is Latin1, but in Debian we rather default to the full

utf8 4-byte character set. See also client.cnf

character-set-server = utf8mb4

collation-server = utf8mb4_general_ci

* InnoDB

InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.

Read the manual for more InnoDB related options. There are many!

Most important is to give InnoDB 80 % of the system RAM for buffer use:

https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size

#innodb_buffer_pool_size = 8G

this is only for embedded server

embedded

This group is only read by MariaDB servers, not by MySQL.

If you use the same .cnf file for MySQL and MariaDB,

you can put MariaDB-only options here

mariadb

This group is only read by MariaDB-10.11 servers.

If you use the same .cnf file for MariaDB of different versions,

use this group for options that older servers don't understand

mariadb-10.11

发现在 50-server.cnf文件中 有 [mysqld] 段的配置,尝试把 表名 大小写 敏感设定写在这里:

即:/etc/mysql/mariadb.conf.d/50-server.cnf

然后重启: systemctl restart mariadb

再登录,查看表名大小写敏感设置: show global variables like '%case%';

总结:在mariadb 10.11以及以后的版本中,要配置表名大小写敏感问题,一般修改修改配置文件: /etc/mysql/mariadb.conf.d/50-server.cnf 在 [mysqld] 段 添加属性:lower_case_table_names=1 然后重启服务

相关推荐
渐暖°3 分钟前
JDBC直连ORACLE进行查询
数据库·oracle
萧曵 丶27 分钟前
Next-Key Lock、记录锁、间隙锁浅谈
数据库·sql·mysql·mvcc·可重复读·幻读
做cv的小昊1 小时前
【TJU】信息检索与分析课程笔记和练习(7)数据库检索—Ei
数据库·笔记·学习·全文检索
zgl_200537791 小时前
ZGLanguage 解析SQL数据血缘 之 标识提取SQL语句中的目标表
java·大数据·数据库·数据仓库·hadoop·sql·源代码管理
莳花微语1 小时前
记录一次OGG进程abended,报错OGG-01431、OGG-01003、OGG-01151、OGG-01296问题的处理
数据库·sql·mysql
尋有緣2 小时前
力扣1355-活动参与者
大数据·数据库·leetcode·oracle·数据库开发
萧曵 丶2 小时前
MySQL三大日志系统浅谈
数据库·sql·mysql
煎蛋学姐2 小时前
SSM校园兼职招聘系统x6u36(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·企业管理·ssm 框架·校园兼职招聘系统
ChineHe3 小时前
Redis基础篇004_Redis Pipeline流水线详解
数据库·redis·缓存
西柚补习生3 小时前
通用 PWM 原理基础教学
数据库·mongodb