0

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)

Behzad
  • 21
  • 5

3 Answers3

1

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/

Raj006
  • 562
  • 4
  • 18
0

try using user = "root" for your user

Jasper
  • 15
  • 5
  • Giving the following error: " Exception - 2003: Can't connect to MySQL server on 'root.mysql.pythonanywhere-services.com:3306'" – Behzad Jun 03 '19 at 19:35
  • @Behzad You may need to grant SELECT permissions to the 'user' of MySQL – Jasper Jun 03 '19 at 19:46
  • When I wrtie "show TABLES from psedeomo$psedemo_test;" I get the following error" ERROR 1044 (42000): Access denied for user 'psedemo'@'%' to database 'psedeomo$psedemo_test'" How should I grant permissions to the users? – Behzad Jun 04 '19 at 05:37
0

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.

Glenn
  • 7,262
  • 1
  • 17
  • 23