I am trying to query a database on my website's hosting service (HostWinds). However, when I run the following code nothing happens. No error, no console logs, nothing.
I found this code from W3 schools guide on MySQL and Node.js.
var mysql = require('mysql');
var con = mysql.createConnection({
host: "webmaxlabs.com",
user: "abc",
password: "123",
database: "USER_wp4"
});
con.connect(function(err) {
if (err) throw err;
con.query("SELECT * FROM wp_posts", function (err, result, fields) {
if (err) throw err;
console.log(result);
});
});
I have MySQL installed, and I'm using the same username and password I use to login to HostWinds. I am also pretty sure I have the right database name. Is my host misnamed? I am not really sure what to use since 'localhost' can't be correct, right? WebMaxLabs.com is listed as my 'Main Domain' in my cPanel. So I figured it might be my host, but I am really not sure. My
Any feedback or information would be very much appreciated. Thank you!