How To Configure And Use MySQL With Django?
I am using Ubuntu 14.04 system and have created a virtual environment also. I want to set up Django with MySQL database (PHPMyAdmin preferably) to work on my project. Please guide
Solution 1:
You can easily install xampp first from https://www.apachefriends.org/download.html
(Follow these steps for xampp installation.)
Then follow the instructions as:
- Install and run xampp from http://www.unixmen.com/install-xampp-stack-ubuntu-14-04/, then start Apache Web Server and MySQL Database from the GUI.
- You can configure your web server as you want but by default web server is at
http://localhost:80
and database atport 3306
, and PhpMyadmin athttp://localhost/phpmyadmin/
- From here you can see your databases and access them using very friendly GUI.
- Create any database(
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
Post a Comment for "How To Configure And Use MySQL With Django?"