[Completely free] Connect to Oracle Always free database (mysql) from public Internet using mysql router

How to run and access Oracle Always free database for entirely free.

 

1. create Database 

Menu > Database > DB Systems




Create DB system


Always Free

username: dbadmin

password: myadminpassword

configure networking: Private subnet default vcn1 

placement: any placement but I chose AD-1


It will take about 5 mins


2. create Compute engine to allow public access redirect to Mysql Database

Menu > Compute > Instances




Create Instance

placement: Same placement I put the DB (AD-1)

Choose a free shape (Ampere) in my case since VM.Standard.E2.1.Micro never being available. 

subnet: Public subnet-default-vcn1 **** important

add or create new SSH key **** important



3. config redirect 

Menu > Networking > Virtual Cloud Networks



add the 2 Ingress Rules

choose default VCN in the list

choose public subnet in the list

choose the only iptable in the list


add 0.0.0.0/0 TCP  allow all access now (need to be restricted later to be more secure)




install MySQL &  router


sudo yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

sudo yum -y install mysql-router



configure MySQL router 

sudo vi /etc/mysqlrouter/mysqlrouter.conf 

replace 10.0.0.11 with your private IP address of MySQL instance


[routing:redirect_classic]
bind_address = 0.0.0.0:3306
destinations = 10.0.0.11:3306
routing_strategy=first-available
[routing:redirect_xprotocol]
bind_address = 0.0.0.0:33060
destinations = 10.0.0.11:33060
protocol = x
routing_strategy=first-available


start the router and check status


sudo systemctl start mysqlrouter.service
sudo systemctl status mysqlrouter.service
sudo systemctl enable mysqlrouter.service


add firewall rules


sudo firewall-cmd --permanent --add-port=3306/tcp
sudo firewall-cmd --permanent --add-port=33060/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-all


4. check the connection from the private subnet

ssh in to the compute engine with ssh key downloaded (or created)


in the instance details, you should see public IP address assigned to the instance


lets say mine is 129.88.88.888


ssh -i /key/to/ssh/foler/ssh-key-2024-12-08.key opc@129.88.88.888


Then, you are in the instance


install client


sudo yum -y install mysql
sudo yum -y install mysql-shell



public IP 129.88.88.888

private IP for MySQL 10.0.0.11

username: dbadmin

password: myadminpassword


check connection in the private network first

sudo mysql –host 10.0.0.11 -u dbadmin -p


if it does not work, trouble shoot with 


ping 10.0.1.11
telnet 10.0.1.11 3306


once you made it work, move on to the public access from your local machine

you can use cli like this or MySQL workbench.


sudo
mysql –host 129.88.88.888 -u dbadmin -p


Good luck 



Comments

Popular posts from this blog

Strapi Can not start server with Cannot read properties of undefined (reading ‘toLowerCase’)