我正在尝试使用MySQL网站https://dev.mysql.com/doc/connector-python/en/将Python连接到MySQL。我已经下载了Python 3.6 MySQL连接器,并设法“导入mysql.connector”。 但是,当我在外壳中使用以下代码时:
connection = mysql.connector.connect(user="username", password="password", host="127.0.0.1"
它产生:
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3306' (10061 No connection could be made because the target machine actively refused it)
什么可能导致此错误?我该如何解决?您有什么建议?