i need to connect to remote mysql database from my nodejs appliacation. Below is my code.
const mysqlssh = require('mysql-ssh');
mysqlssh.connect(
{
host: '572.168.0.68', //ssh login ip
user: 'root', // ssh username
password:'password' //ssh password
},
{
host: '572.168.0.68', //ssh login ip
user: 'dbusername',
password: 'dbpassword',
database: 'mydb'
}
)
.then(client => {
client.query('SELECT * FROM `dbtable`', function (err, results, fields) {
if (err) throw err
console.log(results);
mysqlssh.close()
})
})
.catch(err => {
console.log(err)
})
I am getting the below error for the above code
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlState: '28000',
sqlMessage: "Access denied for user 'dbusername'@'192.168.0.223' (using password: YES)"
const mysqlssh = require('mysql-ssh');
mysqlssh.connect(
{
host: '572.168.0.68', //ssh login ip
user: 'root', // ssh username
password:'password' //ssh password
},
{
host: '572.168.0.68', //ssh login ip
user: 'root', // ssh login username
password: 'dbpassword',
database: 'mydb'
}
)
.then(client => {
client.query('SELECT * FROM `dbtable`', function (err, results, fields) {
if (err) throw err
console.log(results);
mysqlssh.close()
})
})
.catch(err => {
console.log(err)
})
i am getting the below error for my above set up.
{
code: 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251,
sqlState: '08004',
sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client'
}
I am able to login to my mysql instance via putty using the same credentials given in the code. so what is the right way to connect to a remote mysql database with nodejs?