PythonAnywhere Forums

MySQL command denied

There are errors except of Reviews and Home category on my site -> http://hjpark.pythonanywhere.com/ like this (1142, "SELECT command denied to user 'hjpark'@'10.0.0.128' for table 'app_text'")

So, I check MySQL grants for hjpark.

| Grants for hjpark@%                                                                            |
+------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'hjpark'@'%' IDENTIFIED BY PASSWORD <secret> WITH MAX_USER_CONNECTIONS 3 |
| GRANT ALL PRIVILEGES ON `hjpark$app`.* TO 'hjpark'@'%'                                         |
| GRANT ALL PRIVILEGES ON `hjpark$default`.* TO 'hjpark'@'%'

As you can see, GRANT ALL PRIVILEGES ON hjpark$app.* TO 'hjpark'@'%'

I don't know what the problem is.

[edit by admin: formatting]

Interesting! The underlying error is the same problem as in this Stack Overflow answer -- you're not querying the table app_text, or the fully-qualified table hjpark$app.app_text, but rather the table app.app_text. MySQL is giving an unhelpful error message -- instead of saying that you're trying to query a different database to the one you'd expect, it's just saying you don't have permission.

To see this, visit the page that's generating the error and unfold the "Local vars" for the first line in the traceback -- you'll see that the variable sql is set to 'select * From app.app_text'

How is that SQL statement being generated?

Thank you, giles. It works! ^^