I'm working on my first Django project and I kept hitting the limits of sqlite. So I decided to switch to MySQL before adding lots of additional test data. Ever since no page in my Django app loads anymore (neither the admin nor the project pages). I get no error message until Chrome eventually displays "ERR_CONNECTION_REFUSED".
I added the following to my settings:
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'db_name',
'USER': 'user',
'PASSWORD': 'password',
'HOST': '127.0.0.1',
'PORT': '3306',
'OPTIONS': {
'read_default_file': os.path.join(BASE_DIR, 'my.cnf'),
},
The my.cnf file referenced above looks like this:
[client]
database = dbname
user = username
password = password
default-character-set = utf8
[mysqld]
max_allowed_packet = 512M
wait_timeout = 604800
interactive_timeout = 28800
It's definetely being used, as changing the database name in the file causes Django to connect to a different db.
The project uses Celery, so I also modified the Celery result backend:
CELERY_RESULT_BACKEND = 'db+mysql://user:password@localhost:3306/dbname'
Django can connect to the database (see tests like this one: how can I check database connection to mysql in django). I migrated my content according the second answer to this question: What's the best way to migrate a Django DB from SQLite to MySQL? without any errors. All data are present in phpMyAdmin. There's nothing in the MySQL error log. Neither Django nor Celery outputs any error in the debug console/command line. I installed mysqlclient and (for Celery) SQLAlchemy.
Switching back the the original sqlite configuration remedies the problem, so it's definitely linked to the MySQL db. What am I overlooking? Have I missed some vital configuration step? Is there a way to get more error messages? Especially the complete lack of the latter really has me flummoxed.
Trying to get objescts from the database bia the Python console results in ´mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')
, which once more points to a MySQL issue. Closing old connections fixed this error, which did not reappear so far, but the page still doesn't load.