cybozu-go / moco

MySQL operator on Kubernetes using GTID-based semi-synchronous replication.

Home Page:https://cybozu-go.github.io/moco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot login to deployed mysql by mysql command

zhenjunz opened this issue · comments

After deployed moco cluster, I setup port-forward with below command on one cluster node:
kubectl port-forward svc/moco-moco-cluster-01-primary 33306:3306

And then I wanted to login from my laptop with below command:
mysql -h 192.168.3.231 -P 33306 -u moco-admin -p
or
mysql -h 192.168.3.231 -P 33306 -u moco-writable -p
I can see "Enter password: ", but after I paste the password decoded from secret, I got below error message:
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.3.231:33306' (111)
BTW, I used below commands to decode password:

kubectl get secrets moco-moco-cluster-01 -o jsonpath={.data.ADMIN_PASSWORD} | base64 -d
kubectl get secrets moco-moco-cluster-01 -o jsonpath={.data.WRITABLE_PASSWORD} | base64 -d

I tried the following. It worked.

$ kubectl port-forward svc/moco-test-primary 33306:3306 &
$ admin_passwd=$(kubectl get secrets moco-test -o jsonpath='{.data.ADMIN_PASSWORD}' | base64 -d)
$ mysql -h 127.0.0.1 -P 33306 -u moco-admin -p${admin_passwd}
mysql: [Warning] Using a password on the command line interface can be insecure.
Handling connection for 33306
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 116
Server version: 8.0.35 Source distribution

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

What is 192.168.3.231?

192.168.3.231 is the Ip address of the node where I run port-forward
I cannot login when I run mysql(client) on my laptop (outside of kube/moco cluster)
I can login to mysql on localhost too, only cannot login from my laptop(outside kubernetes cluster), with -h as the node ip

So, that's a problem with your network.
My guess is that your laptop cannot connect to 192.168.3.231:33306 for some reason like firewalls.

Closing as this is not a problem with moco.