django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/r

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/linuxpassion/article/details/83629001

问题: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.
展开阅读全文

没有更多推荐了,返回首页