【发布时间】:2020-06-16 13:44:27
【问题描述】:
源代码:
import mysql.connector
from mysql.connector import errorcode
try:
cnx = mysql.connector.connect(user='root',database='menagerie')
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")
else:
print(err)
else:
cnx.close()
我面临的错误: 2003: Can't connect to MySQL server on '127.0.0.1:3306' (10061 No connection could be made because the target machine拒绝了)
【问题讨论】:
-
你没有输入任何密码?
-
你安装了mysql客户端吗?
-
请参考以下链接,看看是否有帮助stackoverflow.com/questions/12993276/…
标签: mysql python-3.x