-
-
Save w0rldart/aa472db45c3817d937a1870a32f77820 to your computer and use it in GitHub Desktop.
version: '3.1' | |
services: | |
db: | |
image: mariadb | |
restart: always | |
command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci --init-connect='SET NAMES UTF8;' --innodb-flush-log-at-trx-commit=0 | |
ports: | |
- 3306:3306 | |
environment: | |
- MYSQL_ROOT_PASSWORD=example | |
- MYSQL_DATABASE=test | |
- MYSQL_USER=testuser | |
- MYSQL_PASSWORD=testpassword |
the mariadb docker image doesn't use 'mysqld' as a startingpoint, but 'mariadbd'.
(the same is for the client, it isn't 'mysql', but 'mariadb')
appending command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
to the docker file won't work.
command: mariadbd --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
will work.
Better is to use the line below; it works both on mariadb and mysql.
command: ['--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
This doesn't work for me for any magic reason. My tables collations and collation of connection is still latin1_swedish_ci, although collation_server is utf8_unicode_ci. I solved it by setting this options to mysql config file directly (my.cnf).
my.cnf:
[mysqld] init_connect=‘SET collation_connection = utf8_unicode_ci’ character-set-server = utf8 collation-server = utf8_unicode_ci [client] default-character-set = utf8
docker-compose.yml:
version: '3.1' services: db: image: mariadb restart: always ports: - 3306:3306 environment: - MYSQL_ROOT_PASSWORD=example - MYSQL_DATABASE=test - MYSQL_USER=testuser - MYSQL_PASSWORD=testpassword volumes: - ./my.cnf:/etc/mysql/my.cnf
p.s. my.cnf is placed near docker-compose.yml in this example. You can put it in another folder, but you should change path in volumes part
This worked for me too. Just a little note, you need to use SINGLE QUOTES around for the line init_connect=‘SET collation_connection = utf8_unicode_ci’
. Thanks mate.
does not work for me