Connect WIX Database to external MySQL Database

Hello Everyone,

I’m a bit new to WIX and especially databases, so please forgive me.

I recently made my own WIX website which is starting to look quite nice in my opinion, but I still need 1 major thing to finalize this which is a connection between my MySQL database which is running on a Ubuntu 18.04 VPS I have bought.

Unfortunately I haven’t managed to do this yet and I could use some advise to point me in the right direction. I have read almost all articles I could find on this but I haven’t found the complete solution.

I think I found a solution using the node.js driver for MySQL available on WIX, but can it be that this is to use data from an external mySQL database but that with this method I can’t connect it to an internal WIX database?

What I already did for this is installed the node.js driver for MySQL available on WIX. What are the next steps I need to undertake? Do I need to do something on the side of my MySQL database or only on the WIX Side?

Do I just need to implement the following code, or isn’t this enough?

ar mysql = require(‘mysql’);
var pool = mysql.createPool({
connectionLimit : 10,
host : ‘example.org’,
user : ‘bob’,
password : ‘secret’,
database : ‘my_db’
});

pool.query(‘SELECT 1 + 1 AS solution’, function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});

Thank you very much for the help!!

So we can assume that you have read about using external datasets with Wix?
https://support.wix.com/en/corvid-by-wix/external-database-collections-1023416
https://github.com/wix/corvid-external-db-mysql-adapter
https://www.wix.com/corvid/reference/external-database-collections.html

Also, it is always good to search the forum for previous posts connected to yours too as you will find many that can help like this one.
https://www.wix.com/corvid/forum/community-discussion/best-way-to-retrieve-data-from-an-external-mysql-db