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 ?
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.
try this
mysql -u root --password=<PASSWORD> -h <CLUSTER_HOST> --port=32695