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!!