Reputation: 105
I've read so many articles, I'm blind, but I'm sure to one of you this will be simple...
I have setup a VPS on MyHosting running Ubuntu 12.04. Try as I might, I can't get MySQL running with Django. When I run python3 manage.py migrate I get an error ending with:
ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I got to this point by:
sudo apt-get install python3
sudo apt-get install python3-setuptools
sudo easy_install3 pip
sudo pip3 install django
The above installed Python 3.2.3 django version: 1.8.4 mysql version: Ver 14.14 Distrib 5.5.44
I edited settings.py to include the following:
DATABASES = {
'default': {
'NAME': 'user_data',
'ENGINE': 'mysql.connector.django',
'USER': 'mysql_user',
'PASSWORD': 'priv4te',
'OPTIONS': {
'autocommit': True,
},
}
}
PS Apache version: Apache/2.2.22
Upvotes: 1
Views: 1225
Reputation: 2654
Try
pip install MySQL-python
If you receive error mysql_config not found
Run
sudo apt-get install python-mysqldb
Upvotes: 0
Reputation: 308799
The Django docs recommend you use mysqlclient, a Python 3 compatible fork of MySQLDB.
You should be able to install it with:
pip3 install mysqlclient
It might be better to use a virtualenv, in which case you can use pip
instead of pip3
in the virtualenv.
pip install mysqlclient
Your databases backend should be django.db.backends.mysql
.
However, mysqlclient requires Python 3.3+ for Python 3. If you want to run Django with MySQL, I believe your options are currently either Python 2.7 or 3.3+.
Upvotes: 1