<p>I am using Minikube and here is my configuration:</p>
<p><code>kubectl describe deployment mysql</code></p>
<p>the output:</p>
<pre><code>Name:                   mysql
Namespace:              default
CreationTimestamp:      Sat, 12 Nov 2022 02:20:54 +0200
Labels:                 &lt;none&gt;
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=mysql
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=mysql
  Containers:
   mysql:
    Image:      mysql
    Port:       3306/TCP
    Host Port:  0/TCP
    Environment:
      MYSQL_ROOT_PASSWORD:  &lt;set to the key 'password' in secret 'mysql-pass'&gt;  Optional: false
    Mounts:
      /docker-entrypoint-initdb.d from mysql-init (rw)
  Volumes:
   mysql-init:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      mysql-init
    Optional:  false
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  &lt;none&gt;
NewReplicaSet:   mysql-77fd55bbd9 (1/1 replicas created)
</code></pre>
<p>when I try to connect to it using mysql workbench:</p>
<p><a href="https://i.stack.imgur.com/sGqJt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sGqJt.png" alt="workbench config" /></a></p>
<p>it shows me:</p>
<p><a href="https://i.stack.imgur.com/w94tA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w94tA.png" alt="failed to connect to mysql" /></a></p>
<p>However, when I execute this line to create a <strong>mysql-client</strong> to try to connect to mysql server:</p>
<p><code>kubectl run -it --rm --image=mysql:8.0 --restart=Never mysql-client -- mysql -h mysql -u skaffold -p</code>
and then enter the password, <strong>it works well!</strong> but still I need to use workbench better.</p>
<p>any help please?</p>
<p>edit 1:</p>
<p>Here is the yaml file for the deployment and the service:</p>
<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
        - name: mysql
          image: mysql
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-pass
                  key: password
          ports:
            - containerPort: 3306
          volumeMounts:
            - name: mysql-init
              mountPath: /docker-entrypoint-initdb.d
      volumes:
        - name: mysql-init
          configMap:
            name: mysql-init
---
apiVersion: v1
kind: Service
metadata:
  name: mysql
  labels:
    name: mysql
spec:
  ports:
    - port: 3306
      targetPort: 3306
      protocol: TCP
  selector:
    app: mysql
</code></pre>

Karim Abdel-Qader
<p>First make sure your service is running, so</p>
<pre><code>kubectl get service
</code></pre>
<p>should return something like :</p>
<pre><code>NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
mysql        ClusterIP   10.99.140.115   &lt;none&gt;        3306/TCP     2d6h
</code></pre>
<p>From that point onwards, I'd try running a port-forward first :</p>
<pre><code>kubectl port-forward service/mysql 3306:3306
</code></pre>
<p>This should allow you to connect even when using a ClusterIP service.</p>
