问题
Is there a possible way to re-establish MySQL connection in Django after it goes down?
I am getting the following error while trying to access MySQL using the get_wsgi_application
in django.core.wsgi
:
(2006,'MYSQL server has gone away')
回答1:
We need to close the old connection to db, which Django had automatically created before.
We can do this by executing the function:
django.db.close_old_connections()
Django automatically creates new connections after closing previous connections.
来源:https://stackoverflow.com/questions/45705509/alternative-for-django-db-close-connection