【问题标题】:MySQLdb Connecting To Database ErrorMySQLdb 连接数据库错误
【发布时间】:2018-05-23 14:28:19
【问题描述】:

我正在尝试连接到我在 pythonanywhere 上的 SQL 数据库并连接我正在运行它。

import MySQLdb

conn = MySQLdb.connect("MYUSERNAME.mysql.pythonanywhere-services.com","MYUSERNAME","DBPASSWORD","DBTABLENAME")

c = conn.cursor()

c.execute("SELECT * from game_db")

rows = c.fetchall()

for eachrow in rows:
    print(eachrow)

我在笔记本电脑上执行此操作,但在尝试连接时出现此错误。

_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on MYUSERNAME.mysql.pythonanywhere-services.com' (10060)")

我需要做某种身份验证还是有其他问题。 谢谢!

【问题讨论】:

    标签: python mysql sql mysql-python pythonanywhere


    【解决方案1】:

    无法从 pythonanywhere 外部访问 pythonanywhere mysql 服务(除非您有付费帐户,在这种情况下您可以使用 ssh 隧道:https://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere/

    【讨论】:

      猜你喜欢
      • 2012-11-04
      • 2014-01-01
      • 2016-06-08
      • 2012-01-21
      • 1970-01-01
      • 2011-09-16
      • 2012-10-29
      相关资源
      最近更新 更多