MYSQL-python的无法连接到本地主机服务器上的Windows 7
问题描述:
我有一个本地的MySQL服务器上的本地主机上运行,Windows 7的MYSQL-python的无法连接到本地主机服务器上的Windows 7
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连接,我没有任何问题(根没有密码)
C:\Users\Alle>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.31-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use information_schema
Database changed
mysql>
但是当我试图通过MySQL-Python 1.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,所以我不能切换连接器。
答
尝试127.0.0.1
而不是本地主机未正确映射的机会,或者您还需要将端口包含在连接中?
尝试使用端口3306和127.0.0.1,没有工作 我出来的想法 – apelliciari 2013-04-28 17:32:47
安装'wamp'或'xamp'并让他们运行你的本地主机服务器应该工作以快速修复...不知道什么是实际问题 – 2013-04-28 17:37:47
不问我为什么,但一个Windows重启解决了这个问题。我打算删除这个问题,或回答自己.. – apelliciari 2013-04-28 17:40:15