0

So I've created a MYSQL DB on the OCI and can connect to it via SSH, I have all the ingress rules set up, the users, etc. What do I put in the host: "....": field in the javascript code? (instead of localhost).

mysqlx
    .getSession( {

        user: 'user', 
        password: 'password',
        host: 'localhost', 
        port: '33060', 
    })

Do I have to do anything else in OCI since the connection is set up as SSH or can I set it up on the public subnet settings as a new ingress rule?

Thanks for any help.

nmsdev
  • 29
  • 6

2 Answers2

1

The answer in OCI is to use the host name and provider of your instance that houses the MYSQL DB and then set your MYSQL Router in OCI with the following:

Step 1 - Install and Configure MySQL Router Assuming your OCI Compute is running Enterprise Linux Enterprise Linux Server release 7.

  1. SSH into the OCI Compute where MySQL Router will be installed

  2. Install MySQL Router. Run:

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

  3. Configure MySQL Router appending to the file /etc/mysqlrouter/mysqlrouter.conf. For example, assuming the MDS private IP is 10.0.0.6, run:

    sudo tee -a /etc/mysqlrouter/mysqlrouter.conf > /dev/null << EOF [routing:redirect_classic] bind_address = localhost:3306 destinations = 10.0.0.6:3306 routing_strategy=first-available

    [routing:redirect_xprotocol] bind_address = localhost:33060 destinations = 10.0.0.6:33060 protocol = x routing_strategy=first-available EOF

  4. Start MySQL Router and check if the service is active (running). Run:

    $ sudo systemctl start mysqlrouter.service $ sudo systemctl status mysqlrouter.service

  5. Automatically start MySQL Router when the Compute instance reboots $ sudo systemctl enable mysqlrouter.service

  6. Add the firewalld rules. Run:

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

Thanks Airton Latori for the assist.

nmsdev
  • 29
  • 6
0

I'm not familiar with OCI specifics, but eventually there should be a hostname or IP address for the MySQL instance (or router) somewhere you can connect to. And, assuming the endpoint "speaks" the X Protocol, that is what you should provide for the host configuration property.

Disclaimer: I'm the lead developer of the MySQL X DevAPI Connector for Node.js

ruiquelhas
  • 1,905
  • 1
  • 17
  • 17