简体   繁体   English

在Pythonanywhere中部署后的MySQL连接错误消息

[英]MySQL connection error message after deployment in Pythonanywhere

I deployed my python program in pythonanywhere. 我在pythonanywhere中部署了python程序。 This program should be connected to MySQL. 该程序应连接到MySQL。 I set up the database and I configured my database setting in the config.ini file as below: 我设置了数据库,并在config.ini文件中配置了数据库设置,如下所示:

[mysql]
host =psedemo.mysql.pythonanywhere-services.com
database =psedemo$psedemo_test
user =psedemo
password =QAZwsx123

When I am running the program from the shell, I am getting the following error in database connection: 从外壳运行程序时,在数据库连接中出现以下错误:

"Exception -  1142 (42000): SELECT command denied to user 'psedemo'@'10.0.0.207' for table 'pseapp_osd_products'". 

Any idea what is the issue? 知道是什么问题吗? (I am sure that databases/table are created and my setting also is right) (我确定已创建数据库/表,并且我的设置也正确)

I am changing my answer as I reviewed Pythonanywhere just now. 我刚刚检查Pythonanywhere时,正在更改答案。 It looks like you have created a python app there and you are using the MySQL db from them. 看起来您已经在其中创建了python应用,并且正在使用它们中的MySQL数据库。 Your password for Pythonanywhere is different from the MySQL password. 您的Pythonanywhere密码与MySQL密码不同。 When you first generate the database, they ask you to create a password for it and mention that it is different from your Pythonanywhere password. 当您首次生成数据库时,他们会要求您为其创建密码,并提及该密码与您的Pythonanywhere密码不同。 You can create a new password in the database page in case you forgot the password. 如果您忘记了密码,可以在数据库页面中创建一个新密码。

Click on your database name in their UI to launch the mysql console. 在用户界面中单击您的数据库名称以启动mysql控制台。 Check the following command. 检查以下命令。

SHOW GRANTS;

It will most probably show that your user has all the GRANTS. 它很可能表明您的用户拥有所有格兰特。 Now, use the connection details on the page, and the password you created, and try to connect again. 现在,使用页面上的连接详细信息以及您创建的密码,然后尝试重新连接。 You can also check their help page to connect to MySQL https://help.pythonanywhere.com/pages/UsingMySQL/ 您也可以检查其帮助页面以连接到MySQL https://help.pythonanywhere.com/pages/UsingMySQL/

尝试为您的用户使用user = "root"

Another source of this error could be a typo in a join. 此错误的另一个来源可能是联接中的错字。 See some of the discussion here and check that the query you're running is correct. 此处查看一些讨论并检查您正在运行的查询是否正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM