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

目录

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

处理步骤:

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

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

mysql 配置大小写不敏感

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

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

总结:在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 然后重启服务

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/670209.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一个基于ComfuUI Api的 AIGC自动绘画实现方案

工作流程图 基本原理已经弄通,下一步要开始编码搬砖了。整个自动绘画的流程如下,暂就不整高深U什么L了,写个简单明了能容易看懂的流程图。UI借用了下墨刀里的AI绘画公开原型 部署节点 整个系统的后端服务典型部署需要3类节点 Aigc Server&…

【考研数学】武忠祥「基础篇」如何衔接进入强化?

如果基础篇已经做完,并且讲义上的例题也都做完了, 那下一步就是该做题了 这个时候,不能盲目做题,做什么题很重要!我当初考研之前,基础也很差,所以考研的时候选了错误的题集,做起来就…

ACPWorkbench_for_BP10

一、菜单 文件菜单包含导入导出所有参数,导出flashbin文件和退出操作。文件菜单显示如下: Import Audio Settings:从音频配置文件中导入音频参数。 Export Audio Settings:将音频设置导出为音频配置文件。 Export Flash Binary Fi…

优化|大语言模型中的优化问题(LoRA相关算法)

一、LoRA 在大语言模型中,参数矩阵 W ∈ R d d W\in \mathbb{R}^{d \times d} W∈Rdd的维度往往可以达到百亿甚至千亿,如果从头开始训练将会特别的消耗时间和资源。因此往往大家都会预先训练好一组初始参数 W 0 ∈ R d d W_0\in \mathbb{R}^{d \times…

MQ如何保证可靠性

📝个人主页:五敷有你 🔥系列专栏:MQ ⛺️稳中求进,晒太阳 消息到达MQ以后,如果MQ不能及时保存,也会导致消息丢失,所以MQ的可靠性也非常重要。 2.数据持久化 为了提高性能&a…

在uniapp里面使用 mp-html 并且开启 latex 功能

在uniapp里面使用 mp-html 并且开启 latex 功能 默认情况下 mp-html 是不会开启 latex 功能的, 如果需要开启 latex 功能是需要到代码操作拉取代码自行打包的。 这里说一下 mp-html 里面的 latex 功能是由 https://github.com/rojer95/katex-mini 提供的技术实现,…

与 Apollo 共创生态:Apollo 7 周年大会的启示与心得

文章目录 前言Apollo X 全新征程Application X 企业预制套件总结 前言 在过去的七年中,Apollo 开放平台经历了一段令人瞩目的发展历程。从最初的构想到如今的成熟阶段,Apollo 已经推出了 13 个版本,吸引了来自全球 170 多个国家和地区的 16 …

大数据技术主要学什么,有哪些课程

大数据技术是指在海量数据的环境下,采集、存储、处理、分析和管理数据的一系列技术与方法。随着互联网、物联网以及各种智能设备的普及,数据量呈爆炸性增长,传统数据处理手段已难以应对,因此大数据技术应运而生,旨在从…

[Collection与数据结构] 七大排序算法汇总

🌸个人主页:https://blog.csdn.net/2301_80050796?spm1000.2115.3001.5343 🏵️热门专栏:🍕 Collection与数据结构 (90平均质量分)https://blog.csdn.net/2301_80050796/category_12621348.html?spm1001.2014.3001.5482 🧀Java …

PyTorch中 DataLoader 和 TensorDataset 的详细解析

DataLoader 和 TensorDataset PyTorch DataLoader 和 TensorDataset 的详细解析DataLoader 介绍DataLoader 的核心功能 TensorDataset 介绍TensorDataset 的核心功能 使用 DataLoader 和 TensorDataset 加载数据关键内容解析 结论 PyTorch DataLoader 和 TensorDataset 的详细解…

VTK —— 三、图形格式 - 示例1 - 读取.vtp文件并输出.ply文件(附完整源码)

代码效果:演示程序读取.vtp后输出.ply文件,使用paraview打开该输出的.ply文件 本代码编译运行均在如下链接文章生成的库执行成功,若无VTK库则请先参考如下链接编译vtk源码: VTK —— 一、Windows10下编译VTK源码,并用V…

堡垒机——网络技术手段

目录 一、简介 1.什么是跳板机 2.跳板机缺陷 3.什么是堡垒机 4.为什么要使用堡垒机 4.1堡垒机设计理念 4.2堡垒机的建设目标 4.3堡垒机的价值 4.4总结 5.堡垒机的分类 6.堡垒机的原理 7.堡垒机的身份认证 8.堡垒机的运维方式常见有以下几种 9.堡垒机其他常见功能…