![](/img/trans.png)
[英]No connection could be made because the target machine actively refused it— How can i check if my server is running and client is able to connect
[英]Can't connect to MySQL server, No connection could be made because the tared machine actively refused it
我正在尝试使用python连接到我的ubuntu VPS上的MySQL数据库,并且正在使用此代码
import pymysql
conn= pymysql.connect(host='remotehost',port='3306',
user='user',password='password',db='db')
a = conn.cursor()
sql = 'SELECT * from `users`;'
a.execute(sql)
countrow = a.execute(sql)
print("Number of rows :",countrow)
data = a.fetchone()
print(data)
当我运行代码时,出现以下错误pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'remotehost' ([WinError 10061] No connection could be made because the target machine actively refused it)")
我已经检查了我的MySQL数据库,并且连接到服务器的“用户”具有“任何主机”主机名。 我似乎无法解决此问题。
通过在/etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address = 127.0.0.1
来bind-address = 127.0.0.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.