How to install MySQLdb module on Django

As many of you would have known, the correct way to install MySQLdb module for use with Django on python 3 is to install mysqlclient using the command below:

pip install mysqlclient

However, there are times after installation, while starting up Django server, the error below still shows, and it was asking whether the mysqlclient module was installed.

import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'

The mysqlclient module was installed after verifying with “pip list”. However, a closer look shows that the version installed was 1.2.5. I am not sure how did that happen. The fix was to force an upgrade of the module:

pip install mysqlclient --upgrade

After that, the error is gone.

1 thought on “How to install MySQLdb module on Django”

Leave a Comment