Here, we will explain the settings for using MySQL as the django database instead of the standard sqlite. In addition, it is assumed that MySQL is installed by MAMP.
First, in manage.py
, specify that you will use MySQL as follows.
manage.py
import pymysql
pymysql.install_as_MySQLdb()
Then write the detailed information of the database in settings.py
.
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME':Database name,
'USER':Username (of your database),
'PASSWORD':Password (of your database),
'HOST': '/Applications/MAMP/tmp/mysql/mysql.sock',
'PORT': '8889' #For MAMP,
}
}
Recommended Posts