New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ER_ACCESS_DENIED_ERROR: #591

Closed
sushantchavan opened this Issue Sep 14, 2013 · 9 comments

Comments

Projects
None yet
7 participants
@sushantchavan

sushantchavan commented Sep 14, 2013

Am sure this has already been sorted out but couldn't find anything conclusive.

I am specifying the database credentials when I create the mysql.createConnection

While connecting to the db it gives with this error Access denied for user 'root'@'triband**********.mtnl.net.in' (using password: YES)'

I am 100 % sure these are not the credentials for the database. How do I solve this ?

@tolgaek

This comment has been minimized.

Show comment
Hide comment
@tolgaek

tolgaek Sep 14, 2013

Contributor

Most likely this issue is that in the database the root user is only allowed to connect from the "localhost".. You need to update it to allow that user to connect from any host or to be safer only from the host you know (triband....)

The instructions are here http://dev.mysql.com/doc/refman/5.5/en/adding-users.html

Contributor

tolgaek commented Sep 14, 2013

Most likely this issue is that in the database the root user is only allowed to connect from the "localhost".. You need to update it to allow that user to connect from any host or to be safer only from the host you know (triband....)

The instructions are here http://dev.mysql.com/doc/refman/5.5/en/adding-users.html

@sushantchavan

This comment has been minimized.

Show comment
Hide comment
@sushantchavan

sushantchavan Sep 15, 2013

Thanks tolgaek. This worked for me.

sushantchavan commented Sep 15, 2013

Thanks tolgaek. This worked for me.

@joliveros

This comment has been minimized.

Show comment
Hide comment
@joliveros

joliveros Jun 1, 2014

I have this issue even though I have these permissions:

mysql> show grants;
+-------------------------------------------------------------------------------------------------------------+
| Grants for RollingRidge@%                                                                                   |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'RollingRidge'@'%' IDENTIFIED BY PASSWORD '*REDACTED'                                 |
| GRANT ALL PRIVILEGES ON `rollingridge`.* TO 'RollingRidge'@'%'                                              |
+-------------------------------------------------------------------------------------------------------------+

joliveros commented Jun 1, 2014

I have this issue even though I have these permissions:

mysql> show grants;
+-------------------------------------------------------------------------------------------------------------+
| Grants for RollingRidge@%                                                                                   |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'RollingRidge'@'%' IDENTIFIED BY PASSWORD '*REDACTED'                                 |
| GRANT ALL PRIVILEGES ON `rollingridge`.* TO 'RollingRidge'@'%'                                              |
+-------------------------------------------------------------------------------------------------------------+

@dougwilson dougwilson added the question label Jun 1, 2014

@hcientist

This comment has been minimized.

Show comment
Hide comment
@hcientist

hcientist Feb 23, 2016

hey team, i know it's been a while on this issue, but i'm seeing a problem like this. I'm getting:

Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'myuser '@'localhost' (using password: YES)

when i run my node script from root (su sudo on ubuntu 14.04) the script works when i run as myuser (anyway it explicitly tells node-mysql to use myuser)

hcientist commented Feb 23, 2016

hey team, i know it's been a while on this issue, but i'm seeing a problem like this. I'm getting:

Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'myuser '@'localhost' (using password: YES)

when i run my node script from root (su sudo on ubuntu 14.04) the script works when i run as myuser (anyway it explicitly tells node-mysql to use myuser)

@sidorares

This comment has been minimized.

Show comment
Hide comment
@sidorares

sidorares Feb 23, 2016

Collaborator

Hi @thegreatmichael

grant entries are separate for local domain socket and tcp connections, when you connect from command line you are likely do it via domain socket ( you can locate it with mysql_config --socket command ) so the solution is to either 1) add grant entry for 'localhost' or 2) connect using socket - see socketPath connection option

Collaborator

sidorares commented Feb 23, 2016

Hi @thegreatmichael

grant entries are separate for local domain socket and tcp connections, when you connect from command line you are likely do it via domain socket ( you can locate it with mysql_config --socket command ) so the solution is to either 1) add grant entry for 'localhost' or 2) connect using socket - see socketPath connection option

@hcientist

This comment has been minimized.

Show comment
Hide comment
@hcientist

hcientist Feb 23, 2016

thanks for the quick response @sidorares ! I'm slightly confused, probably because I provided too little info. see below:

mysql> mysqlgrants;
+---------------------------------------------------------------------------+
| Grants for myuser@localhost                                               |
+---------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'myuser'@'localhost' IDENTIFIED BY PASSWORD <secret>|
| GRANT ALL PRIVILEGES ON `somedbdev`.* TO 'myuser'@'localhost'             |
| GRANT ALL PRIVILEGES ON `somedbprod`.* TO 'myuser'@'localhost'            |
+---------------------------------------------------------------------------+

So, I think i have allowed the user the permission on localhost, should that work?

To be clear:

myuser@mymachine:~somepath$ node myscript.js 

^works! (-: ^

myuser@mymachine:~somepath$ sudo su
root@mymachine:/home/myuser/somepath# node myscript.js 

/home/myuser/somepath/myscript.js:462
      if(err) throw err;
                    ^
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'myuser '@'localhost' (using password: YES)

^ doesn't work )-: ^

hcientist commented Feb 23, 2016

thanks for the quick response @sidorares ! I'm slightly confused, probably because I provided too little info. see below:

mysql> mysqlgrants;
+---------------------------------------------------------------------------+
| Grants for myuser@localhost                                               |
+---------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'myuser'@'localhost' IDENTIFIED BY PASSWORD <secret>|
| GRANT ALL PRIVILEGES ON `somedbdev`.* TO 'myuser'@'localhost'             |
| GRANT ALL PRIVILEGES ON `somedbprod`.* TO 'myuser'@'localhost'            |
+---------------------------------------------------------------------------+

So, I think i have allowed the user the permission on localhost, should that work?

To be clear:

myuser@mymachine:~somepath$ node myscript.js 

^works! (-: ^

myuser@mymachine:~somepath$ sudo su
root@mymachine:/home/myuser/somepath# node myscript.js 

/home/myuser/somepath/myscript.js:462
      if(err) throw err;
                    ^
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'myuser '@'localhost' (using password: YES)

^ doesn't work )-: ^

@dougwilson

This comment has been minimized.

Show comment
Hide comment
@dougwilson

dougwilson Feb 23, 2016

Member

Hi @thegreatmichael, perhaps when you run it as root, it is accessing some different configuration file or something? The error is that the login failed for the user 'myuser ', where there is a space character at the end of the username. I assume you user does not actually have a space, so there is some kind of thing happening in your code adding a space at the end of your username it seems. Try attaching a debugger to your code to see where it is coming from.

Member

dougwilson commented Feb 23, 2016

Hi @thegreatmichael, perhaps when you run it as root, it is accessing some different configuration file or something? The error is that the login failed for the user 'myuser ', where there is a space character at the end of the username. I assume you user does not actually have a space, so there is some kind of thing happening in your code adding a space at the end of your username it seems. Try attaching a debugger to your code to see where it is coming from.

@hcientist

This comment has been minimized.

Show comment
Hide comment
@hcientist

hcientist Feb 23, 2016

thanks @dougwilson YOU GLORIOUS CHAMPION! you are a golden god. indeed, i was originally running with env vars on the command line

env1=something env2=else node script.js

but when i copied that to change it into individual lines, i didn't remove the (not so visible in my editor) trailing spaces!

(It's working)

hcientist commented Feb 23, 2016

thanks @dougwilson YOU GLORIOUS CHAMPION! you are a golden god. indeed, i was originally running with env vars on the command line

env1=something env2=else node script.js

but when i copied that to change it into individual lines, i didn't remove the (not so visible in my editor) trailing spaces!

(It's working)

@mytharcher

This comment has been minimized.

Show comment
Hide comment
@mytharcher

mytharcher Jun 15, 2016

Upgrade the package version to ^2.1.x solved my problem.

mytharcher commented Jun 15, 2016

Upgrade the package version to ^2.1.x solved my problem.

@mysqljs mysqljs deleted a comment from isabellachen Jun 25, 2018

@mysqljs mysqljs deleted a comment from SURESHA2 Jun 25, 2018

@mysqljs mysqljs deleted a comment from ClarenceL Jun 25, 2018

@mysqljs mysqljs locked as resolved and limited conversation to collaborators Jun 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.