6.3 Access MySQL DB System
[continuation of 3.2] [ ... in progress... ]
As already mentioned in tutorial 3.2 The basics - OCI CLI, when successfully providing a MySQL DB instance, it will have a private IP only attached to it.
For security reasons, this seems plausible - you do not want public access to your databases.
How can we login to our databases in this scenario?
A work around for this scenario would be accessing the database through mysql-shell (among other tools)
If you want to connect from an instance to your private MySQL instance you would need an intermediary environment, such as MySQL Router
1. Prepare environment
1.1 Update Firewall Rules on the instance from which you want to deploy to your MySQL instance
root@deploymentmachine:/home/tests/mydb# # or use firewall-cmd
root@deploymentmachine:/home/tests/mydb#
root@deploymentmachine:/home/tests/mydb# ufw allow 3306/tcp
Rules updated
Rules updated (v6)
root@deploymentmachine:/home/tests/mydb# ufw allow 33060/tcp
Rules updated
Rules updated (v6)
root@deploymentmachine:/home/tests/mydb# ufw reload
1.2 Install following MySQL tools:
and
1.3 Update Firewall rules in the Cloud (Ingress Rules)
In order to make these changes work, you need to perform a few changes on the OCI.
You need your instance to communicate with the DB instance.
1.3.1 Go to your DB System, and Select Subnet (marked with green):

1.3.2 Select security list that corresponds to your root compartment:

1.3.3 And add ingress rules:


2. Connect to MySQL system
2.1 Connect to your MySQL system using mysql-shell (provide the password and username you have mentioned in the json file, when creating the database system):
Perform a few tests:
Type Ctrl+D or \exit to leave the mysql-shell:
2.2 Connect to your MySQL using mysql command
... and let's check what we have created so far:
What about SSH?
This is a topic that we need to skip here. When you create the json file for creating the database, there is an option of "sshAuthorizedKeysFile"
However, even if these are added, when deploying the instance, port 22 is not opened. (ports that are not >1024 are not valid for the json creation file).
References:
https://dev.mysql.com/doc/mysql-router/8.0/en/mysql-router-installation-linux.html
https://docs.oracle.com/cd/E17952_01/mysql-shell-8.0-en/mysql-shell-8.0-en.pdf
Last updated