gpt4 book ai didi

python - WinError 10061 由于目标机器主动拒绝,无法建立连接

转载 作者:行者123 更新时间:2023-12-05 07:11:13 26 4
gpt4 key购买 nike

import mysql.connector

mydb = mysql.connector.connect(host="localhost", user="myusername", passwd="mypassword")

print(mydb)

[WinError 10061] No connection could be made because the target machine actively refused it

mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (10061 No connection could be made because the target machine actively refused it)

最佳答案

这对我有用 https://www.digitalocean.com/community/questions/can-t-connect-to-mysql-server-on-ipaddress-10061

默认情况下,mysql 不允许用户从本地主机(环回网络接口(interface))外部连接,您需要启用它才能通过所有网络接口(interface)工作。

修改/etc/mysql/my.cnf

#default
#bind-address = 127.0.0.1
#NEW
bind-address = 0.0.0.0

然后重新启动服务。它仅在我重新启动 VM 时适用于我的 vagrant VM。

关于python - WinError 10061 由于目标机器主动拒绝,无法建立连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60871364/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com