how can I check database connection to mysql in django
All you need to do is start a application and if its not connected it will fail. Other way you can try is on shell try following -
from django.db import connectionsfrom django.db.utils import OperationalErrordb_conn = connections['default']try: c = db_conn.cursor()except OperationalError: connected = Falseelse: connected = True
Run the shell
python manage.py shell
Execute this script
import djangoprint(django.db.connection.ensure_connection())
If it print None
means everything is okay, otherwise it will throw an error if something wrong happens on your db connection
It's an old question but it needs an updated answer
python manage.py check --database default
If you're not using default or if you want to test other databases listed in your settings just name it.
It is available since version 3.1 +
Check the documentation