<p>I'm trying to setup a MySQL pod on Digital Ocean with Kubernetes.</p>

<p>I kept getting this error:</p>

<pre><code>Initializing database
2019-03-05T14:32:58.707421Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-03-05T14:32:58.708753Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-03-05T14:32:58.711746Z 0 [ERROR] Aborting
</code></pre>

<p>My yaml as a lot of stuff but the lines that interest this part of the config are the following.</p>

<pre><code># ------------------- Persistent Volume Claim ------------------- #

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-mysql-volume-claim
  ...
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: do-block-storage

---

# ------------------- Deployment ------------------- #

kind: Deployment
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
...
spec:
      ...
    spec:
      containers:
        - image: mysql:5.7
          ...
          volumeMounts:
            - name: test-mysql-volume
              mountPath: "/var/lib/mysql"
      volumes:
        - name: test-mysql-volume
          persistentVolumeClaim:
            claimName: test-mysql-volume-claim

---
</code></pre>

<p>If I comment out the PVC and the lines relative to PVC in the deployment config, everything works.</p>

<p>Also, if I change </p>

<pre><code>mountPath: "/var/lib/mysql"
</code></pre>

<p>to</p>

<pre><code>mountPath: "/data"
</code></pre>

<p>it works. But I obviously need <code>/var/lib/mysql</code>...</p>

<p>It happens also on brand new clusters.</p>

<p>Any idea?</p>

<p>I had this issue with Kubernetes and MySQL 5.7 as well.</p>
<p>Adding the suggestion from <a href="https://github.com/docker-library/mysql/issues/186#issuecomment-229480846" rel="noreferrer">yosifki</a> to my container's definition got things working.</p>
<blockquote>
<p>A new ext4 disk partition is not usually empty;
there is a lost+found directory, which mysql is known to choke on. You
could try adding --ignore-db-dir=lost+found to the CMD to know for
sure (from <a href="https://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_ignore-db-dir" rel="noreferrer">mysql docs</a>)</p>
</blockquote>
<p>Here's an extract of my working YAML definition:</p>
<pre><code>name: mysql-master
image: mysql:5.7
args:
  - &quot;--ignore-db-dir=lost+found&quot;
</code></pre>
