python - 如何用Python连接cpanel远程数据库
问题描述
我正在尝试远程访问 cpanel 数据库和记录。我使用以下代码进行sql连接,我在cpanel“ remote MySql ”中添加了“ % ”以允许任何ipaddress远程访问数据库。但我仍然收到此错误
import pymysql
# Open database connection
db = pymysql.connect("serverIpAddress","User","Password","DatabaseName")
# prepare a cursor object using cursor() method
cursor = db.cursor()
# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")
# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print ("Database version : %s " % data)
# disconnect from server
db.close()
我收到此错误:
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '184.164.144.130' (timed out)")
解决方案
推荐阅读
- ruby - 如何将分段错误引入 ruby?
- angular - 只显示一次复选框而不是多次
- python - 如何抓取无组织的 HTML 文件
- ios - 如何在设备旋转后重新计算约束
- google-apps-script - google sheet api 能有多慢?
- python - 带有二进制列的 Spark/PySpark collect_set
- python - python argparse 在没有给出参数时获取完整的使用信息
- javascript - 延迟加载取消页面请求
- bootstrap-4 - 引导样式未注入,如何调试
- gradle - 使用 gitlab 中的 gradle 和预配置的部署令牌添加自定义 java 库