gpt4 book ai didi

database - 在 MariaDB 服务器中设置 UTF-8 会忽略 character_set_system

转载 作者:行者123 更新时间:2023-12-01 23:22:57 27 4
gpt4 key购买 nike

我有以下用于 MariaDB 服务器的 Dockerfile 定义文件:

version: "3.8"

...

services:
database:
command: ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
container_name: mariadb
environment:
MARIADB_DATABASE: sample_database
MARIADB_INITDB_SKIP_TZINFO: "true"
MARIADB_PASSWORD_FILE: /run/secrets/mariadb_user_password
MARIADB_ROOT_PASSWORD_FILE: /run/secrets/root_user_password
MARIADB_USER: mariadb
TZ: "Etc/UTC" # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
image: docker.io/library/mariadb:10.6-focal # https://hub.docker.com/_/mariadb/
networks:
- global-network
ports:
- "3306:3306"
restart: on-failure
secrets:
- mariadb_user_password
- root_user_password
stdin_open: true
tty: true
volumes:
- "database-volume:/var/lib/mysql"

我不太精通这个主题,但如果我想检查服务器使用的字符集和排序规则集,我通常会执行这些查询:

> show variables like 'char%';
+------------------------+--------------------------+
|Variable_name |Value |
+------------------------+--------------------------+
|character_set_client |utf8mb4 |
|character_set_connection|utf8mb4 |
|character_set_database |utf8mb4 |
|character_set_filesystem|binary |
|character_set_results |utf8mb4 |
|character_set_server |utf8mb4 |
|character_set_system |utf8mb3 |
|character_sets_dir |/usr/share/mysql/charsets/|
+------------------------+--------------------------+


> show variables like 'collation%';
+--------------------+------------------+
|Variable_name |Value |
+--------------------+------------------+
|collation_connection|utf8mb4_unicode_ci|
|collation_database |utf8mb4_unicode_ci|
|collation_server |utf8mb4_unicode_ci|
+--------------------+------------------+

我的理解是我的设置:--character-set-server=utf8mb4--collat​​ion-server=utf8mb4_unicode_ci 是正确的设置UTF-8 的字符集和排序规则。

现在我的问题是:如何摆脱 character_set_systemutf8mb3 值?它应该与其他值一起设置为 utf8mb4 — 或者这就是我的想法;)

关于如何正确设置的任何线索?

I would like to avoid using any configuration file(s) (like my.cnf) since I'm using the stock Docker image without any modifications.

最佳答案

character_set_system 指定将用于存储标识符和其他内部信息的字符集。

它是 3byte utf8,除非您更改源并重新编译 MariaDB,否则您无法更改它。

从10.6开始,utf8被映射为utf8mb3(以后的版本会映射为utf8mb4)。参见 MDEV-8334

关于database - 在 MariaDB 服务器中设置 UTF-8 会忽略 character_set_system,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67696563/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com