Giter Site home page Giter Site logo

Comments (10)

tianon avatar tianon commented on July 28, 2024 12

This is possible today trivially with command-line flags, as noted/demonstrated in the image description: (https://github.com/docker-library/docs/blob/e72d96051254c263821f8fab32f05e0153221ed9/mariadb/README.md#configuration-without-a-cnf-file)

$ docker run ... mariadb --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

from mariadb-docker.

tanji avatar tanji commented on July 28, 2024 8

@visay You can use the command option to pass a command name and flag.
command: mysqld --flag --flag --flag

from mariadb-docker.

visay avatar visay commented on July 28, 2024 2

@tianon how to integrate these command flags into the docker-compose.yml?

from mariadb-docker.

visay avatar visay commented on July 28, 2024 1

Yes, that's one part for the charset but collation setting is still missing.

from mariadb-docker.

yosifkit avatar yosifkit commented on July 28, 2024 1

+1: docker-library/mysql#14 (comment)

from mariadb-docker.

thaJeztah avatar thaJeztah commented on July 28, 2024

I think this is similar to the feature-request for MySQL; docker-library/mysql#14

from mariadb-docker.

thaJeztah avatar thaJeztah commented on July 28, 2024

True! Just referring to that issue, so that (if possible), a single solution can be found for both MySQL and MariaDB 👍

from mariadb-docker.

visay avatar visay commented on July 28, 2024

@tanji ah yes, working as expected. thanks a lot :)

from mariadb-docker.

Alexhha avatar Alexhha commented on July 28, 2024

Did I miss something but doesn't work for me

MariaDB [(none)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     |
| character_set_connection | latin1                     |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | latin1                     |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.001 sec)

mariadb:10.5

# docker inspect mariadb | jq .[].Config.Cmd
[
  "mysqld",
  "--character-set-server=utf8mb4",
  "--collation-server=utf8mb4_unicode_ci"
]

docker-compose.yml

version: '3'
services:
  mariadb:
    network_mode: host
    image: mariadb:10.5
    container_name: mariadb
    volumes:
      - /opt/docker/mariadb/db-data:/var/lib/mysql
    ports:
      - 3306:3306
    command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
    environment:
      - MARIADB_DATABASE=testdb
      - MARIADB_USER=user
      - MARIADB_PASSWORD=1234567
      - MARIADB_RANDOM_ROOT_PASSWORD=true

from mariadb-docker.

grooverdan avatar grooverdan commented on July 28, 2024

@Alexhha commenting on old closes issues tends to get missed. Please open a new issue next time.

What exactly doesn't work? character_set_server gained the value you set.

$ podman run -d --rm -e MARIADB_DATABASE=testdb -e  MARIADB_USER=user -e  MARIADB_PASSWORD=1234567 -e MARIADB_RANDOM_ROOT_PASSWORD=true --name mdb105-issue-16-test  mariadb:10.5 'mysqld' '--character-set-server=utf8mb4' '--collation-server=utf8mb4_unicode_ci'
3927be7d5acfb6a865fc86491e7a03fb135d17f812ca08111239262ef32ee71a

$ podman exec -ti mdb105-issue-16-test mysql -u user -p1234567 testdb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.11-MariaDB-1:10.5.11+maria~focal 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 [testdb]> create table test (v varchar(300));
Query OK, 0 rows affected (0.012 sec)

MariaDB [testdb]> show create table test\G
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `v` varchar(300) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
1 row in set (0.000 sec)

MariaDB [testdb]> show create database testdb\G
*************************** 1. row ***************************
       Database: testdb
Create Database: CREATE DATABASE `testdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */
1 row in set (0.000 sec)

The table and database are defined with your {character-set,collation}-server server directives.

Where you expecting other character set system variables to change? Character sets are documented on the knowledge base.

from mariadb-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.