无法连接到 MySQL 服务器,无法建立连接,因为 tared 机器主动拒绝它

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 数据库,并且我连接到服务器的 'user' 设置了 "Any host" 主机名。我似乎无法解决这个问题。

已通过注释修复 bind-address = 127.0.0.1/etc/mysql/mysql.conf.d/mysqld.cnf