Docker-compose Can't Connect To Mysql
I'm trying to connect Django project with MySQL using docker. I have the problem when upping docker-compose. It says the next error: super(Connection, self).init(*args, **kwargs2)
Solution 1:
In the "db" part, in your docker-compose :
ports:
- "3307:3306"
Solution 2:
The @Nico answer my fixed your service accessibility from outside of the container, mean if try to access it from the host it should work.
But the error will arise during service to service communication. You should not use publish port in service to service communication or another word you must use container port in service to service communication.
Change the port in connection from 3307
to 3306
DATABASES = {
'default' : {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'database_develop',
'USER': 'root',
'PASSWORD': 'password',
'HOST': 'db',
'PORT': 3306,
'CHARSET': 'utf8',
'COLLATION': 'utf8_bin',
'OPTIONS': {
'use_unicode' : True,
'init_command': 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
},
}
}
Post a Comment for "Docker-compose Can't Connect To Mysql"