Opened 7 years ago

Closed 7 years ago

#29309 closed Cleanup/optimization (needsinfo)

Recommended MySQL Setup Does Not Work Properly

Reported by: ReStartercc Owned by: nobody
Component: Documentation Version: 2.0
Severity: Normal Keywords: Database Setup
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Python 3.6.1
Django 2.0
Mac OS 10.13.3

Following the instruction given in https://docs.djangoproject.com/en/2.0/ref/databases/#mysql-notes, installed pymysql with pip and then modified the settings.py to set up the adaptor according to https://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html, the url given by the official document.

Then when executing python3 manage.py makemigrations error appears which displays ImportError: No module named 'MySQLdb. It is likely that django still uses MySQLdb, which is not supported by python3, as default in the release.

The fix that works for me would be adding following code in the __init__.py of the site to use pymysql to replace mysqldb.

import pymysql
pymysql.install_as_MySQLdb()

Change History (2)

comment:1 by Tim Graham, 7 years ago

Please give a complete traceback of the ImportError. I don't see any MySQLdb imports outside of django.db.backends.mysql so am not sure how this could happen if your settings points to the 'mysql.connector.django' engine.

comment:2 by Tim Graham, 7 years ago

Easy pickings: unset
Resolution: needsinfo
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top