Connect the Django with Mysql Database
In this tutorial we will learn how we will connect mysql with django,Django allows for scalability, re-usability, and rapid development.
Step 1: Install Mysql Server: Download mysql server from click here
https://dev.mysql.com/downloads/mysql/
Step 2 Install Mysql Connector:
pip install mysql_connector
You will see following output:
Step 3 Create Database:open mysql terminal and make database.
Output +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
Step 4 Modife setting.py
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.mysql’,
‘NAME’: ‘test’,
‘USER’: ‘admin’,
‘PASSWORD’: ‘admin’,
‘HOST’: ‘localhost’,
‘PORT’: ‘3306’,
}
}
After modification save this setting you will be connected with database further make class in models.py then migrate.