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


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: "",
          user: "",
          password: "" 

        con.connect(function(err) {
          if (err) throw err;

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'@'' (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.

Arun K

It looks like the user oryxtech_sideE is not granted permission to access the database from host Please confirm the same.

You can grant the user to access the host

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

or any host:

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

Reference: Allow all remote connections, MySQL

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment


MySQL: Access denied for user to database

Mysql PHP Access denied for user ''@'localhost' to database

RDS MySQL ERROR 1045 (28000): Access denied for user when connecting to db from EC2

Testlink Database Error Message: Access denied for user 'root'@'localhost'

Failed to connect: access denied for user - MySQL DB hosted in AWS RDS

Access denied for user MySql

Trigger Alexa notifications from Alexa skill lambda?

Linux MySql Access denied for user

How to fix "Access denied for user 'root'@'' (using password: YES)" when connecting to mysql container?

Cannot connect to MySql database: ERROR 1045 (28000): Access denied for user 'root'@'localhost'

Connecting to an AWS MySQL Database from Scala with Slick

Alexa Skill Set - context.succeed not getting executed from AWS lambda(nodejs)

PHP mysqlnd sha256_password plugin "Access denied", user works from cli mysql

Access denied for user 'root'@'localhost' to database 'drupal'

Access denied for user ''@'localhost' to database laravel

Alexa skill that uses data from an external API with API-KEY

Rails Passenger & mysql Access denied for user

MySQL: Access denied for user 'userName'@'localhost'

mysql error Access denied for user 'root'@'localhost'

MySQL Error: : 'Access denied for user 'root'@'localhost'

Mysql connection is showing Access denied for user

MySQL : Access denied for user ... using password : YES

Access denied for user 'root'@'localhost' in the mysql docker

Access denied for user root - mysql on MAC OS

Wordpress Access denied for user root with MySQL container

mysql_query(): Access denied for user ''@'localhost'

Django - MySQL: 1045 Access Denied for 'user'@'localhost'

Debugging "read time out" for AWS lambda function in Alexa Skill

Access denied for user 'root'@'localhost' from servlet

TOP Ranking