问题:python3 manage.py makemigrations 时报错如下:
django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
解决办法:
django 中settting.py中的DATABASE中的 HOST 修改为:
'HOST': '127.0.0.1',
原因:
- If host is set to
localhost
, then a socket or pipe is used. - If host is set to
127.0.0.1
, then the client is forced to use TCP/IP.