Mysqlpython无法连接到windows7上的localhost服务器

2024-09-21 00:22:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个本地mysql服务器运行在本地主机windows7上

C:\web>mysqld --console
[...]
130428 19:12:37 [Note] mysqld: ready for connections.
Version: '5.5.31-log'  socket: ''  port: 3306  MySQL Community Server (GPL)

如果我尝试连接mysql,我没有问题(root没有密码)

^{pr2}$

但是当我试图通过MySQL-Python1.2.4连接到mysql时,这个失败了

C:\Users\Alle>python
Python 2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> MySQLdb.connect('localhost', 'root', '', 'information_schema')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "C:\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)")

这是我的conf

我受不了了,我不知道该怎么办。。如何调试这个问题并让mysql python正常工作?我需要这个给Django,所以我不能切换连接器。在


Tags: inlocalhostforinformationinitonconnectline

热门问题