I just purchased my own domain including webhosting on a plesk server. Fortunately they also provide a MySQL database. Accessing the DB via the MySQL workbench (locally) works just fine when I insert my credentials (for some reason the only working connection method is 'Standard TCP/IP over SSH'(and it does not even need a location for a privatekey)), but I couldn't find a way to make this work using node.js. (I am using Version 8.11.1).
I decided to use node.js since I want to make some interactive data visualizations with d3 and since I have almost 40000 datapoints I would like to outsource as many processes to the server as possible.
Of course I want to try everything locally as well as on the server.
According to the connection method I used with the workbench, I suspect to use some ssh-modules (just using mysql module won't work either). For now I tried these:
mysql-ssh (https://www.npmjs.com/package/mysql-ssh)
Just putting my credentials (including the privatekey) into the example code just returns this error:
events.js:183 throw er; // Unhandled 'error' event ^ Error: All configured authentication methods failed at tryNextAuth (C:\Users\matth\git\soundstats_elak_titles\node_modules\ssh2\lib\client.js:380:17) at SSH2Stream.onUSERAUTH_FAILURE (C:\Users\matth\git\soundstats_elak_titles\node_modules\ssh2\lib\client.js:591:5) at emitTwo (events.js:126:13) at SSH2Stream.emit (events.js:214:7) at parsePacket (C:\Users\matth\git\soundstats_elak_titles\node_modules\ssh2-streams\lib\ssh.js:3929:10) at SSH2Stream._transform (C:\Users\matth\git\soundstats_elak_titles\node_modules\ssh2-streams\lib\ssh.js:669:13) at SSH2Stream.Transform._read (_stream_transform.js:186:10) at SSH2Stream._read (C:\Users\matth\git\soundstats_elak_titles\node_modules\ssh2-streams\lib\ssh.js:251:15) at SSH2Stream.Transform._write (_stream_transform.js:174:12) at doWrite (_stream_writable.js:397:12) Process finished with exit code 1
from my unsertanding the first block within mysqlssh.connect
is equivalent to the fields in mysql workbench connection configurations SSH Hostname and SSH Username,
while the second block is equivalent to MySQL Hostname and Username
- msql2 & ssh2 (as described on https://medium.com/@devontem/nodejs-express-using-ssh-to-access-mysql-remotely-60372832dd08)
Inserting credentials into this example I first got these messages
(node:6548) UnhandledPromiseRejectionWarning: null (node:6548) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:6548) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
and after waiting for several minutes, the program ends with this message:
events.js:183 throw er; // Unhandled 'error' event ^ Error: read ECONNRESET at _errnoException (util.js:1022:11) at TCP.onread (net.js:628:25) Process finished with exit code 1
here the order of the credential blocks seem to be switched compared to mysql-ssh