<p>my.cnf in kubernetes configmap is not recognized by mysql pod.</p>
<p>This is
<strong>mysql.yaml</strong></p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: *****
  name: *****
spec:
  serviceName: mysql-service
  replicas: 1
  selector:
    matchLabels:
      app: *****
  template:
    metadata:
      labels:   
        app: *****
    spec:
      
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: eks.amazonaws.com/nodegroup
                operator: In
                values:
                - db-node
      containers:
      - name: mysql
        image: mysql:5.7
        args:
           - &quot;--ignore-db-dir=lost+found&quot;
        env:
          - name: MYSQL_ROOT_PASSWORD
            value: password
          - name: MYSQL_USER
            value: mysql
          - name: MYSQL_DATABASE
            value: ****
        ports:
        - containerPort: 3306
          protocol: TCP
        volumeMounts:
        - name: *****
          mountPath: /var/lib/mysql
        - name: mysql-configmap
          mountPath: /etc/mysql/conf.d/mysql.cnf
          subPath: mysql.cnf
      volumes:
        - name: mysql-configmap
          configMap:
            name: mysql-configmap
</code></pre>
<p><strong>configmap.yaml</strong></p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-configmap
  namespace: ****
data:
  mysql.cnf: |
    [client]
    default-character-set=utf8
  
    [mysql]
    default-character-set=utf8
</code></pre>
<p><strong>MySQL Container in my.cnf</strong></p>
<pre><code>root@********:/etc/mysql/conf.d# cat mysql.cnf 
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8
</code></pre>
<p><strong>The file is located in the folder, but the settings I want are not applied.</strong></p>
<pre><code>mysql&gt; show variables like 'char%';                                                                               +--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
</code></pre>
<p>Thank you for reading.<br />
I think it's because my.cnf is root authority, but it's not visible in other use cases.</p>

loanshark
<p>From the official documentation of the docker image found <a href="https://hub.docker.com/_/mysql" rel="nofollow noreferrer">here</a> this could have several reasons.</p>
<p>Check the default mysql configuration under <code>/etc/mysql/my.cnf</code> if there is an <code>includedir</code> statement which includes your <code>/etc/mysql/conf.d</code> directory with your custom configuration.</p>
<p>It is also possible to add encoding options as arguments, meaning that if you cannot fix it via the configmap option you are using right now, you could add extra arguments to your mysql image.</p>
<p>Your statefulset yaml would then look like that:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  namespace: *****
  name: *****
spec:
  serviceName: mysql-service
  replicas: 1
  selector:
    matchLabels:
      app: *****
  template:
    metadata:
      labels:   
        app: *****
    spec:
      
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: eks.amazonaws.com/nodegroup
                operator: In
                values:
                - db-node
      containers:
      - name: mysql
        image: mysql:5.7
        args:
           - &quot;--ignore-db-dir=lost+found&quot;
           - &quot;--character-set-server=utf8mb4&quot;
           - &quot;--character-set-client=utf8mb4&quot;
        env:
          - name: MYSQL_ROOT_PASSWORD
            value: password
          - name: MYSQL_USER
            value: mysql
          - name: MYSQL_DATABASE
            value: ****
        ports:
        - containerPort: 3306
          protocol: TCP
        volumeMounts:
        - name: *****
          mountPath: /var/lib/mysql
        - name: mysql-configmap
          mountPath: /etc/mysql/conf.d/mysql.cnf
          subPath: mysql.cnf
      volumes:
        - name: mysql-configmap
          configMap:
            name: mysql-configmap
</code></pre>
<p>The documentation uses <code>--character-set-server=utf8mb4</code> instead of <code>default-character-set=utf8</code> so you might need to try both options to find out which one is the corret one.</p>
