'How to establish connection with MySQL database which is hosted on Azure Kubernetes cluster
I am working on creating an automated test script in which I am trying to establish connection with database. We are using mySQL database which is hosted on Azure Kubernetes cluster. I access the database through PHP MyAdmin. Now my question is how do I establish a connection with the database. Following lines of code must be used to establish connection:
String dbUrl = "jdbc:mysql://[**ip address**]:[**port**]/[databasename]";
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(dbUrl,username,password);
My concern is , is there a way to get the ip address and port on which MySQL is hosted ?
Solution 1:[1]
Host name an port, usually you should be able to those from your mysql ide (in your case, phpmyadmin) (databasename, you should know but just looking at the name of the db in phpmyadmin)
You can just run this sql, for hostname and port:
show variables where variable_name in ('hostname','port');
However, on a Kubernetes cluster, do you not have to ssh in first?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | bobbybobbobbed |