零基础Python的第391页项目的settings.py文件:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'djdb',
'USER': 'root',
'PASSWORD': '123456',
'HOST': 'localhost',
'PORT': '3306'
}
}
报错: return Database.connect(**conn_params)
File "D:\scs\python\Django\venvdj\lib\site-packages\pymysql\__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "D:\scs\python\Django\venvdj\lib\site-packages\pymysql\connections.py", line 325, in __init__
self.connect()
File "D:\scs\python\Django\venvdj\lib\site-packages\pymysql\connections.py", line 630, in connect
raise exc
django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([WinError 10061] 由于目标计算机
积极拒绝,无法连接。)")