Monu Yadav
Monu Yadav

Reputation: 570

Django Segmentation fault when changing database to mysql in settings.py

My question is similar to the one at error connecting mysql to django which has gone unanswered.

I am using python 3.6.5, mysql server-5.7.29 and Ubuntu 18.04 LTS. I am trying to setup mysql for my django application but I am receiving Segmentation fault.

(env) monu@monu:~/Desktop/ShubhamProject/ShubhamProject$ python manage.py runserver
Segmentation fault (core dumped)

If I use the default sqlite3 database, server comes up.

Database section in settings.py looks like

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'sports_website',
        'USER': 'nonroot',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}

Using the following packages

asgiref==3.2.3
Django==3.0.3
django-crispy-forms==1.8.1
mysqlclient==1.4.6
pytz==2019.3
sqlparse==0.3.0

Upvotes: 0

Views: 848

Answers (2)

user13395607
user13395607

Reputation: 1

this is because django use MySQLdb drive,but MYSQLdb not support python3, so set the drive is pymysql in settings.py: first :pip install pymysql and add: import pymysql pymysql.install_as_MySQLdb()

Upvotes: 0

Zaraki Kenpachi
Zaraki Kenpachi

Reputation: 5740

install pymysql and add below in settings.py on top.

import pymysql
pymysql.version_info = (1, 4, 6, 'final', 0)
pymysql.install_as_MySQLdb()

Upvotes: 2

Related Questions