Something that I'd like to share with you!

Saturday, July 30, 2022

Red Hat OpenShift port forwarding to access MySQL at port 3306

No comments :



Still continuing from my first post about Red Hat OpenShift, here is how to do port forwarding from your locahost port 3306 to MySQL hosted under Red Hat OpenShift. This is to enable the connection to the MySQL using your favorite MySQL client. I'm using HeidiSQL.

1st, OC login to your environment by copying the "oc login" command.


Copy the token displayed.


Open CMD prompt and paste the copied token, assuming that you have already installed the OC tool (OpenShift CLI)


Now, list available pods that you have there.


RSH into you MySQL using "oc rsh <podname>" as below. You should get the shell prompt.


Get user/pass/host/port values from the environment variables using "env|grep <string>" command.


  • MYSQL_PASSWORD = ************
  • MYSQL_USER = userBUW
  • MYSQL_SERVICE_HOST = 172.30.117.29
  • MYSQL_SERVICE_PORT = 3306

Exit RSH with "exit" command and start "oc port-forward <podname> <port>" command as below.


Output "Forwarding from .... > 3306" indicates that the port forwarding is currently active. 

Now, try to access the MySQL using you favorite client. Example below is using HeidiSQL.




No comments :