# Having problem in installing due to mysql connection lost

**URL:** <https://discuss.openedx.org/t/having-problem-in-installing-due-to-mysql-connection-lost/12214>\
**Category:** Tutor Help\
**Tags:** how-to, tutor\
**Created:** [January 31, 2024, 11:30am UTC](https://discuss.openedx.org/t/having-problem-in-installing-due-to-mysql-connection-lost/12214 "2024-01-31T11:30:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shoaib-ali-symbtech](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/shoaib-ali-symbtech/32/6406_2.png) [@shoaib-ali-symbtech](https://discuss.openedx.org/u/shoaib-ali-symbtech)\
**Post date:** [January 31, 2024, 11:30am UTC](https://discuss.openedx.org/t/having-problem-in-installing-due-to-mysql-connection-lost/12214/1 "2024-01-31T11:30:02Z")

</div>

Hi all, I am installing the tutor and facing a connection loss error while migrating the data during the launch command below is the error details

System -MacOs m1 chip  
tutor - 17.0.1

```auto
Traceback (most recent call last):
  File "./manage.py", line 106, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/ __init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/ __init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/migrations/operations/models.py", line 92, in database_forwards
    schema_editor.create_model(model)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/schema.py", line 345, in create_model
    self.execute(sql, params or None)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/schema.py", line 145, in execute
    cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')
Error: Command failed with status 1: docker compose -f /Users/shoaibali/Library/Application Support/tutor/env/local/docker-compose.yml -f /Users/shoaibali/Library/Application Support/tutor/env/local/docker-compose.prod.yml --project-name tutor_local -f /Users/shoaibali/Library/Application Support/tutor/env/local/docker-compose.jobs.yml run --rm lms-job sh -e -c dockerize -wait tcp://mysql:3306 -timeout 20s
dockerize -wait tcp://mongodb:27017 -timeout 20s

echo "Loading settings $DJANGO_SETTINGS_MODULE"

./manage.py lms migrate

# Create oauth2 apps for CMS SSO
# https://github.com/openedx/edx-platform/blob/master/docs/guides/studio_oauth.rst
./manage.py lms manage_user cms cms@openedx --unusable-password
./manage.py lms create_dot_application \
  --grant-type authorization-code \
  --redirect-uris "http://studio.local.overhang.io/complete/edx-oauth2/" \
  --client-id cms-sso \
  --client-secret YqBYvBGNewzD29vHuNL4BN70 \
  --scopes user_id \
  --skip-authorization \
  --update cms-sso cms
./manage.py lms create_dot_application \
  --grant-type authorization-code \
  --redirect-uris "http://studio.local.overhang.io:8001/complete/edx-oauth2/" \
  --client-id cms-sso-dev \
  --client-secret YqBYvBGNewzD29vHuNL4BN70 \
  --scopes user_id \
  --skip-authorization \
  --update cms-sso-dev cms

# Fix incorrect uploaded file path
if [-d /openedx/data/uploads/]; then
  if [-n "$(ls -A /openedx/data/uploads/)"]; then
    echo "Migrating LMS uploaded files to shared directory"
    mv /openedx/data/uploads/* /openedx/media/
    rm -rf /openedx/data/uploads/
  fi
fi

# Create waffle switches to enable some features, if they have not been explicitly defined before
# Completion tracking: add green ticks to every completed unit
(./manage.py lms waffle_switch --list | grep completion.enable_completion_tracking) || ./manage.py lms waffle_switch --create completion.enable_completion_tracking on

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![GarethDowning](https://avatars.discourse-cdn.com/v4/letter/g/eada6e/32.png) [@GarethDowning](https://discuss.openedx.org/u/GarethDowning)\
**Post date:** [June 9, 2024, 5:16pm UTC](https://discuss.openedx.org/t/having-problem-in-installing-due-to-mysql-connection-lost/12214/2 "2024-06-09T17:16:19Z")

</div>

Hi, I’m having a similar issue. When trying to deploy the Tutor package from AWS marketplace I receive an error with lost connection to MySQL:

> Blockquote  
> local launch  
> Running migrations:  
> Applying contenttypes.0001\_initial… OK  
> Applying auth.0001\_initial… OK  
> Applying admin.0001\_initial… OK  
> Applying admin.0002\_logentry\_remove\_auto\_add… OK  
> Applying admin.0003\_logentry\_add\_action\_flag\_choices… OK  
> Applying agreements.0001\_initial… OK  
> Applying announcements.0001\_initial… OK  
> Applying sites.0001\_initial… OK  
> Applying contenttypes.0002\_remove\_content\_type\_name… OK  
> Applying api\_admin.0001\_initial… OK  
> Applying api\_admin.0002\_auto\_20160325\_1604… OK  
> Applying api\_admin.0003\_auto\_20160404\_1618… OK  
> Applying api\_admin.0004\_auto\_20160412\_1506… OK  
> Applying api\_admin.0005\_auto\_20160414\_1232… OK  
> Applying api\_admin.0006\_catalog… OK  
> Applying api\_admin.0007\_delete\_historical\_api\_records… OK  
> Applying assessment.0001\_initial…Traceback (most recent call last):  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 82, in \_execute  
> return self.cursor.execute(sql)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py”, line 73, in execute  
> return self.cursor.execute(query, args)  
> File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py”, line 206, in execute  
> res = self.\_query(query)  
> File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py”, line 319, in \_query  
> db.query(q)  
> File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py”, line 254, in query  
> \_mysql.connection.query(self, query)  
> MySQLdb.OperationalError: (2013, ‘Lost connection to MySQL server during query’)  
> The above exception was the direct cause of the following exception:  
> Traceback (most recent call last):  
> File “./manage.py”, line 106, in   
> execute\_from\_command\_line([sys.argv[0]] + django\_args)  
> File “/openedx/venv/lib/python3.8/site-packages/django/core/management/ **init**.py”, line 419, in execute\_from\_command\_line  
> utility.execute()  
> File “/openedx/venv/lib/python3.8/site-packages/django/core/management/ **init**.py”, line 413, in execute  
> self.fetch\_command(subcommand).run\_from\_argv(self.argv)  
> File “/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py”, line 354, in run\_from\_argv  
> self.execute(\*args, \*\*cmd\_options)  
> File “/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py”, line 398, in execute  
> output = self.handle(\*args, \*\*options)  
> File “/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py”, line 89, in wrapped  
> res = handle\_func(\*args, \*_kwargs)  
> File “/openedx/venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py”, line 244, in handle  
> post\_migrate\_state = executor.migrate(  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py”, line 117, in migrate  
> state = self.\_migrate\_all\_forwards(state, plan, full\_plan, fake=fake, fake\_initial=fake\_initial)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py”, line 147, in \_migrate\_all\_forwards  
> state = self.apply\_migration(state, migration, fake=fake, fake\_initial=fake\_initial)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py”, line 232, in apply\_migration  
> self.record\_migration(migration)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/executor.py”, line 244, in record\_migration  
> self.recorder.record\_applied(migration.app\_label, migration.name)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/recorder.py”, line 86, in record\_applied  
> self.ensure\_schema()  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/recorder.py”, line 63, in ensure\_schema  
> if self.has\_table():  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/migrations/recorder.py”, line 56, in has\_table  
> tables = self.connection.introspection.table\_names(cursor)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/introspection.py”, line 52, in table\_names  
> return get\_names(cursor)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/base/introspection.py”, line 47, in get\_names  
> return sorted(ti.name for ti in self.get\_table\_list(cursor)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/introspection.py”, line 69, in get\_table\_list  
> cursor.execute(“SHOW FULL TABLES”)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 66, in execute  
> return self.\_execute\_with\_wrappers(sql, params, many=False, executor=self.\_execute)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 75, in \_execute\_with\_wrappers  
> return executor(sql, params, many, context)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 84, in \_execute  
> return self.cursor.execute(sql, params)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/utils.py”, line 90, in **exit**  
> raise dj\_exc\_value.with\_traceback(traceback) from exc\_value  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py”, line 82, in \_execute  
> return self.cursor.execute(sql)  
> File “/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py”, line 73, in execute  
> return self.cursor.execute(query, args)  
> File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py”, line 206, in execute  
> res = self.\_query(query)  
> File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py”, line 319, in \_query  
> db.query(q)  
> File “/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py”, line 254, in query  
> \_mysql.connection.query(self, query)  
> django.db.utils.OperationalError: (2013, ‘Lost connection to MySQL server during query’)  
> Error: Command failed with status 1: docker compose -f /home/tutor/.local/share/tutor/env/local/docker-compose.yml -f /home/tutor/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor\_local -f /home/tutor/.local/share/tutor/env/local/docker-compose.jobs.yml run --rm lms-job sh -e -c dockerize -wait tcp://mysql:3306 -timeout 20s  
> dockerize -wait tcp://mongodb:27017 -timeout 20s  
> echo “Loading settings $DJANGO\_SETTINGS\_MODULE”  
> ./manage.py lms migrate  
> Create oauth2 apps for CMS SSO  
> [https://github.com/openedx/edx-platform/blob/master/docs/guides/studio\_oauth.rst](https://github.com/openedx/edx-platform/blob/master/docs/guides/studio_oauth.rst)  
> ./manage.py lms manage\_user cms cms@openedx --unusable-password  
> ./manage.py lms create\_dot\_application   
> –grant-type authorization-code   
> –redirect-uris “[http://studio.www.credotraining.com/complete/edx-oauth2/](http://studio.www.credotraining.com/complete/edx-oauth2/)”   
> –client-id cms-sso   
> –client-secret 25jeicQuGEiMIBgGrnO5ZwI6   
> –scopes user\_id   
> –skip-authorization   
> –update cms-sso cms  
> ./manage.py lms create\_dot\_application   
> –grant-type authorization-code   
> –redirect-uris “[http://studio.www.credotraining.com:8001/complete/edx-oauth2/](http://studio.www.credotraining.com:8001/complete/edx-oauth2/)”   
> –client-id cms-sso-dev   
> –client-secret 25jeicQuGEiMIBgGrnO5ZwI6   
> –scopes user\_id   
> –skip-authorization   
> –update cms-sso-dev cms  
> Fix incorrect uploaded file path  
> if [-d /openedx/data/uploads/]; then  
> if [-n “$(ls -A /openedx/data/uploads/)”]; then  
> echo “Migrating LMS uploaded files to shared directory”  
> mv /openedx/data/uploads/_ /openedx/media/  
> rm -rf /openedx/data/uploads/  
> fi  
> fi  
> Create waffle switches to enable some features, if they have not been explicitly defined before  
> Completion tracking: add green ticks to every completed unit  
> (./manage.py lms waffle\_switch --list | grep completion.enable\_completion\_tracking) || ./manage.py lms waffle\_switch --create completion.enable\_completion\_tracking on
