Can't connect to MySQL server (111) even after

2019-07-23 17:44发布

问题:

I wrote a few lines of code that sends data to a remote MySQL database.

import MySQLdb
db = MySQLdb.connect("MyServerIP","MyUserName","MYPwd","MyDB")

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute("INSERT INTO mytable(Column1) VALUES (Value1);")

# Fetch a single row using fetchone() method.
data = cursor.fetchone()

# disconnect from server
db.close()

Error:

Can't connect to MySQL server (111)

I tried:

  • Putting in comment: bind-address: Doesn't work.

  • Changed bind-address initial value to my server IP: Doesn't work.

Any help?