MySQLdb连接数据库错误

时间:2017-12-09 14:36:54

标签: python mysql sql mysql-python pythonanywhere

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

chmod a+x xde-2.22.1-x86_64.AppImage
./xde-2.22.1-x86_64.AppImage

我是通过笔记本电脑执行此操作,并在尝试连接时收到此错误。

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)

我需要进行某种身份验证,还是存在其他问题。 谢谢!

1 个答案:

答案 0 :(得分:1)

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