<p>I have a the same issue that I have seen other users have about permission for mysql folder in the percona image. But I have it in Kubernetes, and I am not sure exactly how I can chown of the volume before the image is applied.</p>
<p>This is the yaml:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: db
  labels:
    app: db
    k8s-app: magento
spec:
  selector:
    app: db
  ports:
  - name: db
    port: 3306

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: db
spec:
  selector:
    matchLabels:
      app: db
  serviceName: db
  template:
    metadata:
      labels:
        app: db
        k8s-app: magento
    spec:
      containers:
      - args:
        - --max_allowed_packet=134217728
        - &quot;--ignore-db-dir=lost+found&quot;
        volumeMounts:
        - mountPath: /var/lib/mysql
          name: data
        env:
        - name: MYSQL_DATABASE
          valueFrom:
            configMapKeyRef:
              name: config
              key: DB_NAME
        - name: MYSQL_PASSWORD
          valueFrom:
            configMapKeyRef:
              name: config
              key: DB_PASS
        - name: MYSQL_USER
          valueFrom:
            configMapKeyRef:
              name: config
              key: DB_USER
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            configMapKeyRef:
              name: config
              key: DB_ROOT_PASS
        image: percona:5.7
        name: db
        resources:
          requests:
            cpu: 100m
            memory: 256Mi
      restartPolicy: Always
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi

</code></pre>
<p>Same issue, but in docker:
<a href="https://stackoverflow.com/questions/54507881/docker-compose-mysqld-cant-create-write-to-file-var-lib-mysql-is-writable">Docker-compose : mysqld: Can&#39;t create/write to file &#39;/var/lib/mysql/is_writable&#39; (Errcode: 13 - Permission denied)</a></p>
<p>How to fix it in Kubernetes?</p>

justadev
<p>I found this solution and it works:</p>
<pre><code>      initContainers:
      - name: take-data-dir-ownership
        image: alpine:3
        # Give `mysql` user permissions a mounted volume
        # https://stackoverflow.com/a/51195446/4360433
        command:
        - chown
        - -R
        - 999:999
        - /var/lib/mysql
        volumeMounts:
        - name: data
          mountPath: /var/lib/mysql
</code></pre>
