Last time we tried to connect to a MySQL DB instance in OCI with Cloud Shell, we needed to use the bastion service. See here.
Now, we also have the possibility to bypass the bastion host as Cloud Shell offers the possibility to change network.
As you know, in Oracle Cloud Infrastructure, a MySQL DB instance is not exposed in the public subnet and doesn’t have the possibility to get a public IP.
In the Private Subnet, we often have a security list allowing all internal IPs (from public and private subnet of the VCN) to connect to the MySQL port(s).
If the security list is present, we can click on the Cloud Shell icon and once loaded, change the network:
We need to create a new Private Network Definition:
In case you don’t have the ports open for MySQL in the Security List, you can then use a previously created Network Security Group dedicated to access the MySQL port(s), 3306 and 33060, for the Classic and X protocol.
During the Private Network Definition, we need to use the same VCN and the same Private Subnet used by the MySQL DB Instanc
Once created, we need to wait for the Cloud Shell to be connected:
Once connected, you can use MySQL Shell in the Cloud Shell console to connect to MySQL:
We use the Private IP address of the MySQL DB System… and we are connected !
Cloud Shell on Oracle Cloud Infrastructure (OCI) provides a simplified, user-friendly interface for connecting to MySQL HeatWave Database Service using MySQL Shell, making database management an effortless task. And all via the browser !