It's 2019 and I am amazed this doesn't seem to be the default. https://stackoverflow.com/questions/55437104/minimal-setup-for-mariadb-to-handle-emojis
In the docs under Configuration without a cnf file there is a mention of $ docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:tag --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci. Does this ensure news databases can handle Emojis? I am not sure.
Searching around, it's not clear how to ensure I setup a DB with utf8 with docker-compose.yml. https://github.com/search?q=mariadb+utf8mb4_unicode_ci+filename%3Adocker-compose.yml&type=Code
Is it done with envs or command? Command API just seems non-idiomatic.
$ docker run -dit --rm --name some-mariadb -e MYSQL_DATABASE=馃惂 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
3dac222bc5a47b5d9a8362a23645a3106e2a0b7966cad7e6b206b0270c29a28f
$ docker exec -it some-mariadb mysql -uroot -pmy-secret-pw
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.12-MariaDB-1:10.3.12+maria~bionic mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| 馃惂 |
+--------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]>
Your docker-compose would then include a command: line, however yaml doesn't seem to accept unicode characters and gave me a ReaderError: unacceptable character when I tried
version: '3'
services:
db:
image: mariadb
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE="F"
- MYSQL_USER=user
- MYSQL_PASSWORD=password
command:
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
ports:
- "3306:3306"
$ docker exec -it mariadb-235_db_1_19d657251b7a mysql -uroot -proot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.13-MariaDB-1:10.3.13+maria~bionic mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SHOW VARIABLES LIKE '%collation%';
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | latin1_swedish_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+----------------------+--------------------+
3 rows in set (0.003 sec)
MariaDB [(none)]>
If you have further questions you could try asking the Docker Community Forums, the Docker Community Slack, or Stack Overflow. Since these repositories are for issues with the image and not necessarily for questions of usability
Most helpful comment
Your docker-compose would then include a
command:line, however yaml doesn't seem to accept unicode characters and gave me aReaderError: unacceptable characterwhen I triedIf you have further questions you could try asking the Docker Community Forums, the Docker Community Slack, or Stack Overflow. Since these repositories are for issues with the image and not necessarily for questions of usability