<p>I deployed wordpress and mysql,everything works fine I just want to know how can I access my mysql from command line</p>

<pre><code>My services
wordpress           LoadBalancer   10.102.29.45     &lt;pending&gt;     80:31262/TCP     39m
wordpress-mysql     ClusterIP      None             &lt;none&gt;        3306/TCP         42m
</code></pre>

<p>Describe pod</p>

<pre><code>kubectl describe pod wordpress-mysql-5fc97c66f7-jx42l
Name:               wordpress-mysql-5fc97c66f7-jx42l
Namespace:          default
Priority:           0
PriorityClassName:  &lt;none&gt;
Node:               minikube/10.0.2.15
Start Time:         Mon, 11 Mar 2019 08:49:19 +0100
Labels:             app=wordpress
                    pod-template-hash=5fc97c66f7
                    tier=mysql
Annotations:        &lt;none&gt;
Status:             Running
IP:                 172.17.0.15
Controlled By:      ReplicaSet/wordpress-mysql-5fc97c66f7
Containers:
  mysql:
    Container ID:   docker://dcfe9037ab14c3615aec4000f89f28992c52c40a03581215d921564e5b3bec58
    Image:          mysql:5.6
    Image ID:       docker-pullable://mysql@sha256:36cad5daaae69fbcc15dd33b9f25f35c41bbe7e06cb7df5e14d8b966fb26c1b4
    Port:           3306/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 11 Mar 2019 08:50:33 +0100
    Ready:          True
</code></pre>

<p>Is there any analogy to docker?
 How to query mysql?</p>

<p>If I try with exec</p>

<pre><code>kubectl exec -it wordpress-mysql-5fc97c66f7-jx42l -- /bin/bash
root@wordpress-mysql-5fc97c66f7-jx42l:/# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
</code></pre>

Richard Rublev
<p>To fix the issue, you have to set up a password for your MySQL user.</p>

<p>According to the official <a href="https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/#create-a-secret-for-mysql-password" rel="nofollow noreferrer">documentation</a>, you need to create a Secret object containing your password:</p>

<pre><code>kubectl create secret generic mysql-pass --from-literal=password=YOUR_PASSWORD
</code></pre>

<p>And update your deployment spec with the following part:</p>

<pre><code>env:
  - name: MYSQL_ROOT_PASSWORD
    valueFrom:
      secretKeyRef:
        name: mysql-pass
        key: password
</code></pre>
