gpt4 book ai didi

python - Mysql-python 无法连接到 Windows 7 上的本地主机服务器

转载 作者:太空宇宙 更新时间:2023-11-03 12:29:09 24 4
gpt4 key购买 nike

我有一个在本地主机上运行的本地 mysql 服务器,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,我没有任何问题(root 没有密码)

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 连接到 mysql 时1.2.4 这失败:

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 可能是 localhost 没有正确映射,或者您可能还需要在连接中包含该端口?

关于python - Mysql-python 无法连接到 Windows 7 上的本地主机服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16265602/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com