Reputation: 27
I created a database called (mydatabase) and user with full privileges called (admin) identified by (admin), then i tried to connect my django project with mydatabase by the following code below:
django_project\mysettings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydatabase',
'USER': 'admin',
'PASSWORD': 'admin',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
Everything was working as expected until i changed that DATABASES dictionary from the default value in file above and it resulted by the following error when i tried to run the server with py manage.py runserver
MySQLdb._exceptions.OperationalError: (2013, "Lost connection to MySQL server at 'handshake: reading inital communication packet', system error: 0")
django.db.utils.OperationalError: (2013, "Lost connection to MySQL server at 'handshake: reading inital communication packet', system error: 0")
I didn't provide the traceback for the error as it seemed unneccessary, I would provide it if needed
I have both mysql client and mysql connector modules installed :
mysql-connector-python 8.0.19
mysqlclient 1.4.6
Upvotes: 1
Views: 312
Reputation: 176
Port 3306 is the default port for the MySQL Protocol, which is used by the mysql client You are using 5432 which is default for Postgresql.
Upvotes: 2