How to connect external mysql server in docker container

I have built a Django app in a docker container. And run it on the server with ip 192.168.1.13. And I installed Django settings.py to connect the mysql server at 192.168.1.6. This is an external independent server. But when I start the container it always says that access is denied for user xxx@192.168.1.13. How can Django connect to the ip of the docker host but not to a specific server ip?

Any body can help me solve this problem? Many thanks.

There are two servers.

Server A is 192.168.1.13. The dock-docker container runs on it.

Server B - 192.168.1.6. This is a mysql server.

And I want the django container to connect to server B. But it reported that it cannot connect to its host server.

+3


source to share


1 answer


It looks like you have granted access to your user, which is only accessible through localhost. Try the following on your MySQL server:

GRANT ALL PRIVILEGES ON * . * TO 'xxx'@'192.168.1.13';

      



Note that the IP address after @

above refers to the address to which the MySQL client connects (your Django container), not the address of the MySQL server.

+1


source







All Articles