[英]Access MySQL-DB (on plesk server) via Node.js
我刚刚购买了自己的域,包括在plesk服务器上进行网站托管。 幸运的是,他们还提供了一个MySQL数据库。 当我插入凭据时,通过MySQL工作台(本地)访问DB可以很好地工作(由于某些原因,唯一的工作连接方法是“基于SSH的标准TCP / IP”(并且甚至不需要私钥的位置)) ,但是我找不到使用node.js进行这项工作的方法。 (我正在使用版本8.11.1)。
我决定使用node.js,因为我想用d3进行一些交互式的数据可视化,并且由于我有将近40000个数据点,我想将尽可能多的进程外包给服务器。
当然,我想在本地以及在服务器上尝试所有操作。
根据我在工作台上使用的连接方法,我怀疑使用了某些ssh模块(仅使用mysql模块也无法使用)。 现在我尝试了这些:
mysql-ssh( https://www.npmjs.com/package/mysql-ssh )
只需将我的凭据(包括私钥)放入示例代码中,就会返回此错误:
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
从我unsertanding内的第一块mysqlssh.connect
相当于MySQL工作台的连接配置SSH主机名和用户名SSH的字段,而第二块是等效到MySQL主机名和用户名
在此示例中插入凭据,我首先得到了这些消息
(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.
等待几分钟后,程序以以下消息结束:
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
在这里,与mysql-ssh相比,凭据块的顺序似乎已切换
看起来mysql-ssh在后台使用了node-mysql2,它目前不支持MySQL 8.0使用的新的默认身份验证插件。
更多详细信息,请参见此处 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.