2013-10-18 34 views
0

當我使用Python 2.7連接到MySQL我得到:無法從Django的網站與Python 2.7連接到MySQL,但是是確定與Python 2.5

Traceback (most recent call last): 
    File "C:\Programs\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 48, in inner_run 
    self.validate(display_num_errors=True) 
    File "C:\Programs\Python27\lib\site-packages\django\core\management\base.py", line 249, in validate 
    num_errors = get_validation_errors(s, app) 
    File "C:\Programs\Python27\lib\site-packages\django\core\management\validation.py", line 102, in get_validation_errors 
    connection.validation.validate_field(e, opts, f) 
    File "C:\Programs\Python27\lib\site-packages\django\db\backends\mysql\validation.py", line 14, in validate_field 
    db_version = self.connection.get_server_version() 
    File "C:\Programs\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 313, in get_server_version 
    self.cursor() 
    File "C:\Programs\Python27\lib\site-packages\django\db\backends\__init__.py", line 75, in cursor 
    cursor = self._cursor() 
    File "C:\Programs\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 297, in _cursor 
    self.connection = Database.connect(**kwargs) 
    File "C:\Programs\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect 
    return Connection(*args, **kwargs) 
    File "C:\Programs\Python27\lib\site-packages\MySQLdb\connections.py", line 187, in __init__ 
    super(Connection, self).__init__(*args, **kwargs2) 
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)") 

相同的代碼/ MySQL實例正常工作時我用Pyhton 2.5與MySQLdb的驅動程序。 我該如何解決它? 謝謝!我使用MySQL-python-1.2.4.win-amd64-py2.7和Python 2.7.3(默認,2012年4月10日,23:24:47)[MSC v.1500 64位(AMD64)]

+0

是MySQLdb的對Python2.7的要求。我不知道是否有不同的MySQLdb的2.7,你需要您目前擁有的Python 2.5 –

+1

你確定你已經安裝了python2.7正確的MySQL-python的連接器? – ScotchAndSoda

+0

@ScotchAndSoda我的Python 2.7.3(默認情況下,2012年4月10日,23點24分47秒)[MSC v.1500 64位(AMD64)]對win32和我安裝了MySQL-蟒-1.2.4.win-amd64- py2.7 – dbf

回答