How To Use MySQL with Django Application on Ubuntu 14.04

237

How To Use MySQL with Django Application on Ubuntu 14.04: we assume already Installed Mysql –

Open Terminal and Create Database;

mysql -u root -p

show databases;

Output like:

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| d8 |
| demod8 |
| drupal8 |
| mysql |
| n360 |
| new_review |
| performance_schema |
| review |
| stuabroad |
| tesing |
| welcometoholidays |
| wordpress |
+--------------------+
14 rows in set (0.42 sec)

Create Database:

create database first_django

  1. Run given command:

sudo apt-get install python3-dev libmysqlclient-dev

Example

(my_vartual_env) rizwan-s-tech@Rizwan-s-Tech:~/first_python$ sudo apt-get install python3-dev libmysqlclient-dev

2. pip install mysqlclient

Example:

(my_vartual_env) rizwan-s-tech@Rizwan-s-Tech:~/first_python$ pip install mysqlclient

 

Add to Settings.py:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'first_django',
'USER': 'username',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
}
}

 

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here