Package Exports
- mysql-ssh
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mysql-ssh) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
MySQL SSH
Sets up a MySQL connection inside an SSH tunnel. This is practical when you want to reach a database which is only accessible through a webserver. Even if the database server is not located on the webserver itself.
API
.connect(obj sshConfig, obj dbConfig)
sshConfigshould be an object according to thessh2package.dbConfigshould be an object according to themysql2package.- Returns a Promise, containing a connection from the
mysql2package.
Usage
const mysqlssh = require('mysql-ssh');
const fs = require('fs');
mysqlssh.connect(
{
host: 'my-ssh-server.org',
user: 'me-ssh',
privateKey: fs.readFileSync(process.env.HOME + '/.ssh/id_rsa')
},
{
host: 'my-db-host.com',
user: 'me-db',
password: 'secret',
database: 'my-db-name'
}
)
.then(client => {
client.query('SELECT * FROM `users`', function (err, results, fields) {
if (err) throw err
console.log(results);
})
})
.catch(err => {
console.log(err)
})