从 AWS lambda(Alexa 技能的后端)连接到外部 Mysql 数据库 returns "Access denied for user" 消息

Connecting to external Mysql database from AWS lambda (back end of Alexa skill) returns "Access denied for user" message

我正在 Javascript 中编写一个 Alexa lambda 函数来连接到我的外部数据库。我已经使用相同的用户名和密码成功访问了该数据库。我已经从笔记本电脑的 noded_modules 文件夹上传了 mysql 代码。这是 Javascript 代码:

        var mysql = require('mysql');

        var con = mysql.createConnection({
          host: "www.oryxtech.net",
          user: "",
          password: "" 
        });

        con.connect(function(err) {
          if (err) throw err;
          console.log("Connected!");
        });

这是来自 lambda 控制台的错误消息:

2020-01-03T23:08:10.885Z    1100009f-24bf-4980-a2e1-27044988eb9d    Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'oryxtech_sideE'@'ec2-3-85-146-115.compute-1.amazonaws.com' (using password: YES)
    at Handshake.Sequence._packetToError (/var/task/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Handshake.ErrorPacket (/var/task/mysql/lib/protocol/sequences/Handshake.js:123:18)
    at Protocol._parsePacket (/var/task/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/var/task/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/var/task/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/var/task/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/var/task/mysql/lib/Connection.js:91:28)
    at Socket.<anonymous> (/var/task/mysql/lib/Connection.js:525:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    --------------------
    at Protocol._enqueue (/var/task/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/var/task/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/var/task/mysql/lib/Connection.js:119:18)
    at mysqlDB.init (/var/task/mysqlDB.js:17:13)
    at getWelcomeResponse (/var/task/index.js:64:19)
    at onLaunch (/var/task/index.js:263:5)
    at exports.handler (/var/task/index.js:328:13)

是我做错了什么,还是我漏掉了一步?在此先感谢您的帮助。

用户 oryxtech_sideE 似乎未被授予从主机 ec2-3-85-146-115.compute-1.amazonaws.com 访问数据库的权限。请确认相同。

您可以授权用户访问主机

GRANT ALL ON *.* to 'oryxtech_sideE'@'ec2-3-85-146-115.compute-1.amazonaws.com' IDENTIFIED BY 'password'; 

或任何主机:

GRANT ALL ON *.* to 'oryxtech_sideE'@'%' IDENTIFIED BY 'password'; 

参考: Allow all remote connections, MySQL

希望对您有所帮助。