简体   繁体   中英

aws ec2 ubuntu ami hosted mysql instance connection denied error

aws ec2 setup details: ubuntu18.04 ami, mysql8 installed and user created with native password
the my sql db instance allows connection from workbench on laptop
have a nodejs app hosted on heroku connecting same db and it works
hosted the same nodejs app on that same ec2 instance but testing with postman for that gives error
host for db in node app: public ip of ec2
user: mysqluser
password:mysqlpassword
port:3306

security group for ec2 allows every connection to nodejs app on port 3001 and mysql port 3306

connection string for nodejs app in heroku and ec2 is same and have also tried using localhost for host in ec2 nodejs app

error faced "Access denied for user 'ubuntu'@'localhost' (using password: YES)"
also error faced "Client does not support authentication protocol requested by server; consider upgrading MySQL client"
this authentication error happens if host is changed from localhost to public ip of ec2
this user is ubuntu even after changing user to mysql user in connection string
this error only happens for nodejs app hosted on same ec2 instance with mysqldb doesnt happen for workbench or heroku nodejs app

this is for anyone facing same issue it was solved after using sudo npm start didnt include sudo before

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM