fix: Be able to connect to SQL in containers.

By default if you use `localhost` as the `HOST` value for mysql, it
tries to connect to a file socket on disk rather than trying to connect
to the loopback hostname.  This prevents us from running MySQL in a
container while running the LMS on your local machine.

Setting the host to `127.0.0.1` forces the SQL connection to go over TCP
instead. This allows you to map your container port to your localhost
without any issues.
This commit is contained in:
Feanil Patel
2023-05-08 10:07:00 -04:00
parent 4e043de248
commit c3dc07ed7d

View File

@@ -1640,7 +1640,7 @@ DATABASES = {
'ATOMIC_REQUESTS': True,
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.mysql',
'HOST': 'localhost',
'HOST': '127.0.0.1',
'NAME': 'edxapp',
'OPTIONS': {},
'PASSWORD': 'password',
@@ -1650,7 +1650,7 @@ DATABASES = {
'read_replica': {
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.mysql',
'HOST': 'localhost',
'HOST': '127.0.0.1',
'NAME': 'edxapp',
'OPTIONS': {},
'PASSWORD': 'password',
@@ -1660,7 +1660,7 @@ DATABASES = {
'student_module_history': {
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.mysql',
'HOST': 'localhost',
'HOST': '127.0.0.1',
'NAME': 'edxapp_csmh',
'OPTIONS': {},
'PASSWORD': 'password',