2

I have a got a kubernetes mysql pod which is exposed as a nodePort like shown below

apiVersion: v1
kind: Service
metadata:
  name: demo-mysql
  labels:
    app: demo
spec:
  type: NodePort
  ports:
    - port: 3306
      nodePort: 32695

I am trying to access this mysql server using the command below

mysql -u root -h 117.213.118.86 -p 32695

but I get this error

ERROR 2003 (HY000): Can't connect to MySQL server on '117.213.118.86' (111)

What am I doing wrong here ?

2 Answers 2

1

try this

mysql -u root --password=<PASSWORD> -h <CLUSTER_HOST> --port=32695
Sign up to request clarification or add additional context in comments.

Comments

1

If you want to connect to a remote mysql service, you have to specify an endpoint that has the remote service's ip addrress like this:

apiVersion: v1
kind: Endpoints
metadata:
  name: demo-mysql
subsets:
  - addresses:
      - ip: 192.0.2.42
    ports:
      - port: 3306

More details here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.