N
N
nottobacco2022-01-06 17:58:55
MySQL
nottobacco, 2022-01-06 17:58:55

How to get rid of an encoding error when creating a container?

The situation is the following. Through docker-compose, I create a container based on the official image of the latest version of MySQL with the command command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci.

But I connect to the database through Workbench and see that the database has the correct utf8mb4 encoding set, but the default comparison is utf8mb4_unicode_ci instead of the expected utf8mb4_unicode_ci, and the mysql> show charset command, among other encodings, displays the string utf8mb4 | UTF-8 Unicode | utf8mb4_unicode_ci | 4.

How to force containers to run in the required encoding and comparison?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hx510b, 2022-03-13
@hx510b

Try adding mysql file to config like this:

[mysqld]
init_connect='SET collation_connection = utf8mb4_unicode_ci'
collation-server=utf8mb4_unicode_ci

To push the config inside the docker image, use the -v option
-v /local/path/to/hosts/config/collation.conf:/etc/my.cnf.d/collation.conf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question