简体   繁体   中英

MySQL connection error message after deployment in Pythonanywhere

I deployed my python program in pythonanywhere. This program should be connected to MySQL. I set up the database and I configured my database setting in the config.ini file as below:

[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. It looks like you have created a python app there and you are using the MySQL db from them. Your password for Pythonanywhere is different from the MySQL password. 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. 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. 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/

尝试为您的用户使用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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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