python mySQL 连接不上
- 报错
(Pythin , MySQL) DatabaseError: 2003 (HY000): Can't connect to MySQL server on '196.xxx.xxx.xxx:3306' (113)
import mysql.connector
mydb = mysql.connector.connect(
host="196.xxx.xxx.xxx",
user="xxxxx",
passwd="xxxxxx",
database="Unnamed" # I tried to put "cloud_db" and "Unnamed" is not work
)
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM webpage")
myresult = mycursor.fetchall()
for row in myresult:
print(row)
- error output
MySQLInterfaceError Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/mysql/connector/connection_cext.py in _open_connection(self)
267 try:
268 self._cmysql.connect(**cnx_kwargs)
269 self._cmysql.converter_str_fallback = self._converter_str_fallback
MySQLInterfaceError: Can't connect to MySQL server on '196.xxx.xxx.xxx:3306' (113)
The above exception was the direct cause of the following exception:
DatabaseError Traceback (most recent call last)
4 frames
/usr/local/lib/python3.8/dist-packages/mysql/connector/connection_cext.py in _open_connection(self)
271 self.converter.str_fallback = self._converter_str_fallback
272 except MySQLInterfaceError as err:
273 raise get_mysql_exception(
274 msg=err.msg, errno=err.errno, sqlstate=err.sqlstate
275 ) from err
DatabaseError: 2003 (HY000): Can't connect to MySQL server on '196.xxx.xxx.xxx:3306' (113)
我需要怎么改