Search code examples
mysqlnode.jscentos7mysql2node-mysql2

Can connect to remote mysql DB through mysql workbench but not through mysql2 (NodeJS)


I'm trying to connect my NodeJS application to my remote MySQL Database, but it keeps giving me a 1045 error ('ER_ACCESS_DENIED_ERROR'). From the same workstation, I can connect to the same database through MySQL Workbench perfectly fine.

This leads me to think that the problem was with my NodeJS setup, but copying the database to a local setup and then connecting it, worked just fine. For the sake of testing, I made a DB user with host: %, and from my Node app, I connect to the IP address where the database is hosted. I'm hosting it on my own Centos 7 droplet with my workstation IP whitelisted.

The error message I get is:

"Access denied for user '[the test user I made]'@'[workstation ip]' (using password: YES)"

Any help is much appreciated!


Solution

  • Apparently (atleast I think) the password I used, had forbidden characters in it (not sure which ones). Generating a simpler password solved the issue!