如何使用Python连接cpanel远程数据库

时间:2018-10-13 16:31:28

标签: python python-3.x cpanel mysql-python

我正在尝试访问cpanel数据库并进行远程记录。我将以下代码用于sql连接,已在面板“ 远程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)")

0 个答案:

没有答案