<p>OpenShift:</p>

<p>I have the below MySQL Deployment</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-master
spec:
  selector:
    matchLabels:
      app: mysql-master
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql-master
    spec:
      volumes:
        - name: mysql-persistent-storage
          persistentVolumeClaim:
            claimName: ro-mstr-nfs-datadir-claim
      containers:
      - image: mysql:5.7
        name: mysql-master
        env:
        - name: MYSQL_SERVER_CONTAINER
          value: mysql
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: MYSQL_ROOT_PASSWORD
        - name: MYSQL_DATABASE
          valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: MYSQL_DATABASE
        - name: MYSQL_USER
          valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: MYSQL_USER
        - name: MYSQL_PASSWORD
          valueFrom:
              secretKeyRef:
                name: mysql-secret
                key: MYSQL_PASSWORD
        ports:
        - containerPort: 3306
          name: mysql-master
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
</code></pre>

<p>I created a deployment using this yml file which created a deployment and pod which is successfully running.</p>

<p>And I have a configmap</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: ro-mstr-mysqlinitcnfgmap
data:
  initdb.sql: |-
    CREATE TABLE aadhaar ( name varchar(255) NOT NULL,
    sex char NOT NULL, birth DATE  NOT NULL, death DATE  NULL,
    id int(255) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) );
    CREATE USER 'usera'@'%' IDENTIFIED BY 'usera';
    GRANT REPLICATION SLAVE ON *.* TO 'usera' IDENTIFIED BY 'usera';
    FLUSH PRIVILEGES;
</code></pre>

<p>Now I need to patch the above deployment using this configmap.  I am using the below command</p>

<pre><code>oc patch deployment mysql-master -p '{ "spec": { "template": { "spec": { "volumes": [ { "name": "ro-mysqlinitconf-vol", "configMap": { "name": "ro-mstr-mysqlinitcnfgmap" } } ], "containers": [ { "image": "mysql:5.7", "name": "mysql-master", "volumeMounts": [ { "name": "ro-mysqlinitconf-vol", "mountPath": "/docker-entrypoint-initdb.d" } ] } ] } } } }'
</code></pre>

<p>So the above command is successful, I validated the Deployment description and inside the container it placed the initdb.sql file successfully, and recreated the pod. But the issue is it has not created the aadhaar table. I think it has not executed the initdb.sql file from <code>docker-entrypoint-initdb.d</code>.</p>

Abdul
<p>If you dive into the entrypoint script in your image (<a href="https://github.com/docker-library/mysql/blob/75f81c8e20e5085422155c48a50d99321212bf6f/5.7/docker-entrypoint.sh#L341-L350" rel="nofollow noreferrer">https://github.com/docker-library/mysql/blob/75f81c8e20e5085422155c48a50d99321212bf6f/5.7/docker-entrypoint.sh#L341-L350</a>) you can see it only runs the initdb.d files if it is also creating the database the first time. I think maybe you assumed it always ran them on startup?</p>
