<p>Here is my MySQL </p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: abc-def-my-mysql
  namespace: abc-sk-test
  labels:
    project: abc
    ca: my
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: abc-def-my-mysql
        project: abc
        ca: my
    spec:
      containers:
      - name: mysql
        image: mysql:5.6
        args: ["--default-authentication-plugin=mysql_native_password", "--ignore-db-dir=lost+found"]
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "root"
        - name: MYSQL_DATABASE
          value: "my_abc"
        - name: MYSQL_USER
          value: "test_user"
        - name: MYSQL_PASSWORD
          value: "12345"
        volumeMounts:
         - mountPath: /var/lib/mysql
           name: abc-def-my-mysql-storage
      volumes:
      - name: abc-def-my-mysql-storage
        persistentVolumeClaim:
         claimName: abc-def-my-mysql-pvc
</code></pre>

<p>I would like to add another user to mysql so real users can connect to it. Instead of using "test_user". how can I add another user, is it like adding any other environment variable to the above config </p>

<p>Mount a "create user script" into container's <code>/docker-entrypoint-initdb.d</code> directory. it will be executed once, at first pod start.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Pod
metadata:
  name: mysql
spec:
  containers:
  - name: mysql
    image: mysql
    .....
    env:
    - name: MYSQL_ROOT_PASSWORD
      value: "root"
    .....
    volumeMounts:
      - name: mysql-initdb
        mountPath: /docker-entrypoint-initdb.d
  volumes:
  - name: mysql-initdb
    configMap:
      name: initdb

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: initdb
data:
  initdb.sql: |-
    CREATE USER 'first_user'@'%' IDENTIFIED BY '111' ;
    CREATE USER 'second_user'@'%' IDENTIFIED BY '222' ;
</code></pre>

<p>Test:</p>

<pre><code>kubectl exec -it &lt;PODNAME&gt; -- mysql -uroot -p -e 'SELECT user, host FROM mysql.user;'

    +-------------+------+
    | user        | host |
    +-------------+------+
    | first_user  | %    |
    | second_user | %    |
    | root        | %    |
    +-------------+------+
</code></pre>

<p>See <a href="https://hub.docker.com/_/mysql/" rel="noreferrer">Initializing a fresh instance</a> Mysql Docker Hub image:</p>

<blockquote>
  <p>When a container is started for the first time, a new database with
  the specified name will be created and initialized with the provided
  configuration variables. Furthermore, it will execute files with
  extensions <code>.sh,</code> <code>.sql</code> and <code>.sql.gz</code> that are found in
  <code>/docker-entrypoint-initdb.d</code>. Files will be executed in alphabetical
  order. </p>
  
  <p>You can easily populate your <code>mysql</code> services by mounting a SQL
  dump into that directory and provide custom images with contributed
  data. SQL files will be imported by default to the database specified
  by the MYSQL_DATABASE variable.</p>
</blockquote>
