bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
8.93k stars 9.18k forks source link

MySQL - Cannot create database with UTF8MB4 #3040

Closed greggbjensen closed 4 years ago

greggbjensen commented 4 years ago

Which chart: mysql v6.14.4

Describe the bug When I start the container I get warning messages about UTF8MB4. If I set master.config to UTF8MB4 the container fails to start.

--character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
--collation-server: 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.

I am using Pimcore which requires UTF8MB4, so I explicitly set the master.config to UTF8MB4:

master:
  config: |-
    [mysqld]
    ...
    character-set-server=UTF8MB4
    collation-server=UTF8MB4

    [client]
    ...
    default-character-set=UTF8MB4

    [manager]
    ...

Now the container fails with no messages after Installing database:

image

To Reproduce Steps to reproduce the behavior:

  1. Create a mysql.yaml values file with a database to be created and the master.config:

    fullnameOverride: test-mysql
    root:
      password: someRootPass
    db:
      name: mydatabase
      user: myuser
      password: myDataPass
    replication:
      enabled: false
    master:
      config: |-
        [mysqld]
        default_authentication_plugin=mysql_native_password
        skip-name-resolve
        explicit_defaults_for_timestamp
        basedir=/opt/bitnami/mysql
        plugin_dir=/opt/bitnami/mysql/plugin
        port=3306
        socket=/opt/bitnami/mysql/tmp/mysql.sock
        datadir=/bitnami/mysql/data
        tmpdir=/opt/bitnami/mysql/tmp
        max_allowed_packet=16M
        bind-address=0.0.0.0
        pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
        log-error=/opt/bitnami/mysql/logs/mysqld.log
        character-set-server=UTF8MB4
        collation-server=UTF8MB4
    
        [client]
        port=3306
        socket=/opt/bitnami/mysql/tmp/mysql.sock
        default-character-set=UTF8MB4
        plugin_dir=/opt/bitnami/mysql/plugin
    
        [manager]
        port=3306
        socket=/opt/bitnami/mysql/tmp/mysql.sock
  2. Install the helm chart with the mysql.yaml as values:

    helm install test-mysql bitnami/mysql --values=.\mysql.yaml --wait
  3. The container will start in Kubernetes and get to Creating database then the container will restart with no other messages.

Expected behavior Database is created with UTF8MB4 encoding.

Version of Helm and Kubernetes:

version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"}
version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"}
PS D:\Dev\Git\experlogix-app-asset-library> kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.5", GitCommit:"e6503f8d8f769ace2f338794c914a96fc335df0f", GitTreeState:"clean", BuildDate:"2020-06-26T03:47:41Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.10", GitCommit:"ba1ce4122d67b0f7399a41afbbd8a7258d22ecb8", GitTreeState:"clean", BuildDate:"2020-04-21T00:13:25Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
greggbjensen commented 4 years ago

I was able to get it to work, without any warnings, if I removed all character set lines from the master.config:

fullnameOverride: test-mysql
root:
  password: someRootPass
db:
  name: mydatabase
  user: myuser
  password: myDataPass
replication:
  enabled: false
master:
  config: |-
    [mysqld]
    default_authentication_plugin=mysql_native_password
    skip-name-resolve
    explicit_defaults_for_timestamp
    basedir=/opt/bitnami/mysql
    plugin_dir=/opt/bitnami/mysql/plugin
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    datadir=/bitnami/mysql/data
    tmpdir=/opt/bitnami/mysql/tmp
    max_allowed_packet=16M
    bind-address=0.0.0.0
    pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
    log-error=/opt/bitnami/mysql/logs/mysqld.log

    [client]
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    plugin_dir=/opt/bitnami/mysql/plugin

    [manager]
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
andresbono commented 4 years ago

Hi @greggbjensen, you can use the value image.debug=true to get more information about what is going on. Adding the following lines to your mysql.yaml file showed what is causing the issue:

image:
  debug: true
$ kubectl logs -f test-mysql-master-0
...
mysql 11:25:41.46 INFO  ==> Installing database
2020-07-07T11:25:41.469443Z 0 [System] [MY-013169] [Server] /opt/bitnami/mysql/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 33
2020-07-07T11:25:41.470239Z 0 [ERROR] [MY-010933] [Server] Unknown collation: 'UTF8MB4'.

Then I checked Supported Character Sets and Collations. Executing the SHOW CHARACTER SET; in a working deployment (without a custom values file):

ROOT_PASSWORD=$(kubectl get secret --namespace default mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode)
kubectl exec -it mysql-master-0 -- mysql -uroot -p${ROOT_PASSWORD} -e 'SHOW CHARACTER SET;'

+----------+---------------------------------+---------------------+--------+
| Charset  | Description                     | Default collation   | Maxlen |
+----------+---------------------------------+---------------------+--------+
...
| utf8     | UTF-8 Unicode                   | utf8_general_ci     |      3 |
| utf8mb4  | UTF-8 Unicode                   | utf8mb4_0900_ai_ci  |      4 |
+----------+---------------------------------+---------------------+--------+

So it seems the collation doesn't have the same format than the charset. Changing that in your mysql.yaml file made the trick:

     pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
     log-error=/opt/bitnami/mysql/logs/mysqld.log
     character-set-server=UTF8MB4
-    collation-server=UTF8MB4
+    collation-server=utf8mb4_0900_ai_ci

     [client]
     port=3306
stale[bot] commented 4 years ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

stale[bot] commented 4 years ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

stale[bot] commented 4 years ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.