You can follow this article to make Django get connection with MySQL Database.
Connect Django With MySQL Database
-
First you should launch XAMPP and open phymyadmin page. And then create a new table called “mydjango” (or any name you want).
-
Delete the unused file called “db.sqlite3”.
-
Next in settings.py file, change the DATABASE code as following.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydjango',
'USER': 'root',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '3316', # you should check your own port, usually it should be '3306'
}
}
-
After that, in pycharm terminal, input this command
python manage.py migrate
. -
Until now, open mydjango database, you will see below.
-
Now, when you try to get into your admin page using your password set before, you will get an error.
-
To fix this, you should create a new superuser for this. So in pycharm terminal, input
python manage.py createsuperuser
. You can just create a new superuser with the same information as before to cover the old message. -
Finally, refresh admin page and login again. You will see this page if you get successful.