Reputation: 361
I have xampp on my system. I installed Django also. From last two days I am trying to integrate MySQL with Django. I also tried for Django with xampp but each individual tutorial/process from various links and youtube have failed. Now I can't even run my apache server from xampp.
I also tried Bitnami Django Stack but it clashes with my existing xampp's apache and MySQL ports.
My question is how can I use MySQL(I use xampp for development so I want to use MySQL which is installed with xampp) as a database for Django projects?
Upvotes: 2
Views: 754
Reputation: 582
DB_NAME
) which you want to use on your Django Project.Edit your settings.py file
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DB_NAME',
'HOST': '127.0.0.1',
'PORT': '3306',
'USER': 'root',
'PASSWD': '',
}}
Install the following packages in the virtualenv (if you're using django on virtualenv, which is more preferred):
sudo apt-get install libmysqlclient-dev
pip install MySQL-python
That's it!! you have configured Django with MySQL in a very easy way.
Now run your Django project:
python manage.py migrate
python manage.py runserver
Upvotes: 2
Reputation: 7332
You have to install mysql-python module to make it working
Follow this tutorial to setup mysql in your django environment.
Upvotes: 0
Reputation: 474171
You need to set DATABASES dictionary in settings.py
and point to your mysql server:
A dictionary containing the settings for all databases to be used with Django. It is a nested dictionary whose contents maps database aliases to a dictionary containing the options for an individual database.
Example:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydatabase',
'USER': 'myuser',
'PASSWORD': 'myuserpassword',
'HOST': '127.0.0.1',
'PORT': '3306'
}
}
Upvotes: 2