I\'m attempting to run a webserver that uses an RDS database with EC2 inside a docker container.
I\'ve setup the security groups so the EC2 host\'s role is allowed
When I tried to connect to AWS RDS in inside of docker container, I got "Access denied for user 'username'@'xxx.xx.xxx.x' (using password: YES)"
error.
To solve this issue, I did below two ways:
I created new user and assigned grant.
$ CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
$ GRANT ALL ON newuser@'%' IDENTIFIED BY 'password';
$ FLUSH PRIVILEGES;
Added global DNS address 8.8.8.8
into docker container when run docker, so that the docker container can resolve IP address of AWS RDS from domain name.
$ docker run --name backend-app --dns=8.8.8.8 -p 8000:8000 -d backend-app
Then I connected from inside of docker container to AWS RDS, successfully.