I am writing an Alexa lambda function in Javascript to connect to my external database. I have successfully accessed that database with the same username and password. I have uploaded the mysql code from the noded_modules folder on my laptop. Here is the Javascript code:
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!");
});
and this is the error message from the lambda console:
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)
Am I doing something wrong, or is there a step I have omitted? Thanks in advance for any help.
It looks like the user oryxtech_sideE
is not granted permission to access the database from host ec2-3-85-146-115.compute-1.amazonaws.com
. Please confirm the same.
You can grant the user to access the host
GRANT ALL ON *.* to 'oryxtech_sideE'@'ec2-3-85-146-115.compute-1.amazonaws.com' IDENTIFIED BY 'password';
or any host:
GRANT ALL ON *.* to 'oryxtech_sideE'@'%' IDENTIFIED BY 'password';
Reference: Allow all remote connections, MySQL
Hope this helps.