简体   繁体   English

Django:无法连接到mysql

[英]Django: cannot connect to mysql

I am new to Django and I try to follow the official tutorial. 我是Django的新手,我尝试按照官方教程进行操作。 since I want to connect to mysql (installed on my computer, and i checked mysql module does exit in python command line), I set the ENGINE in setting.py to be django.db.backends.mysql . 因为我想连接到mysql(安装在我的计算机上,我检查mysql模块确实退出python命令行),我将来自setting.py的ENGINE设置为django.db.backends.mysql。 and then I tried to run 然后我试着跑

    python manage.py syncdb

then I got error message like this: 然后我得到这样的错误信息:

   Error loading MySQLdb module

and I cannot run 我无法逃避

   pip install mysql-python

the error msg is: 错误消息是:

   Unable to find vcvarsall.bat

so what is this error? 那么这个错误是什么? and honestly I am not sure about the difference between mysql-python and mysql-connector-python. 老实说,我不确定mysql-python和mysql-connector-python之间的区别。 Since i tried with "pip install mysql-connector-python" and it tells me that requirement already satisfied... 因为我尝试了“pip install mysql-connector-python”,它告诉我需求已经满足......

You need to download the windows binary installer for the MySQL drivers for Python. 您需要为Python的MySQL驱动程序下载Windows二进制安装程序。 Installing from source will not work since you do not have the development headers in Windows. 从源代码安装将无法正常工作,因为您在Windows中没有开发标题。

You need to install the mysql python connector 你需要安装mysql python连接器

sudo apt-get install python-mysqldb sudo apt-get install python-mysqldb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM