Answer the question
In order to leave comments, you need to log in
Mysql module not connecting to my hosting (mysql)?
Hello!
I have this code:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'ip моего хостинга',
user : 'имя юзера',
password : 'пароль',
database : 'имя базы'
});
connection.connect();
var query = connection.query('SELECT * FROM `wp_posts` WHERE `post_type` = "job" limit 1,50', function(err, result) {
console.log(err);
console.log(result);
});
connection.end();
$ node sql.js
{ [Error: connect ETIMEDOUT]
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true }
undefined
Answer the question
In order to leave comments, you need to log in
hint
var mysql = require('mysql');
var connection = mysql.createConnection(
{
host : 'localhost',
user : 'your-username',
password : 'your-password',
database : 'wordpress',
}
);
connection.connect();
var query = connection.query('SELECT * FROM wp_posts');
query.on('error', function(err) {
throw err;
});
query.on('fields', function(fields) {
console.log(fields);
});
query.on('result', function(row) {
console.log(row.post_title);
});
connection.end();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question