【发布时间】:2019-03-27 03:47:10
【问题描述】:
我做了一个 python -m pip install mysql-connector 并且能够通过 python 成功运行import mysql.connector。但是当我试图运行下面的代码时。
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="yourusername",
passwd="yourpassword"
)
print(mydb)
失败,InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (10061 No connection could be made because the target machine positively denied)
由于我为 mysql.connector 安装了 pip,所以我不确定用户和密码。
【问题讨论】:
-
你确定你的端口是对的?