>>> db=MySQLdb.connect(passwd="king123",db="thangs",host="localhost",port=3306,user="user")
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
db=MySQLdb.connect(passwd="king123",db="thangs",host="localhost",port=3061,user="user")
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)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
我在正確的端口上運行它,它仍然給我錯誤。任何人都可以給我任何想法請python mysql連接錯誤
mysql有一個很好的功能,連接到「localhost」實際上會使用本地unix域套接字,而不是tcp。確保python正在查找套接字文件的正確位置。 –
我正在使用windows –
您是否啓用了Windows防火牆? –