启动manage.py提示 连接数据库异常

django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.
0.0.1' ([Errno 10061] )")

 

此时cmd.exe  输入mysql指令同样有异常提示:

C:\Windows\system32>mysql
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

此时使用windows任务管理器查看mysql进程是否异常,可以发现进程中无 "mysqld.exe"进程

此时通过使用以下命令重启mysql进程

Windows下:(可以保存为.bat文件)

  1.点击“开始”->“运行”(快捷键Win+R)。
  2.启动:输入 net stop mysql
  3.停止:输入 net start mysql

 

cmd.exe再次运行manage.py 服务

C:\Python27\Python.exe E:\Django\API\Guest manage.py runserver

提示正常:

Performing system checks...

System check identified no issues (0 silenced).
May 17, 2017 - 02:07:58
Django version 1.10.3, using settings 'guest.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.