mysql-python socket鏈接錯誤

前提:python

cygwin 裏經過 mysql-python模塊 鏈接 windows版本的mysqlmysql

經過 socket不能鏈接 , 改成tcpsql


以下鏈接shell

 conn = MySQLdb.connect(host='localhost',port=3306,user='xxx',passwd='xxx',db='xxx',charset='utf8')

出錯信息:windows

_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2)")


代碼中  host="localhost"  或 host參數爲空 都默認爲socket方式鏈接, 改成host='127.0.0.1', 執行成功socket

 conn = MySQLdb.connect(host='127.0.0.1',port=3306,user='xxx',passwd='xxx',db='xxx',charset='utf8')
相關文章
相關標籤/搜索