PDOException: SQLSTATE[42000]: Syntax error or access violation: 1143 SELECT command denied to user ''@'%' for column 'uid' in table 'uc_orders': show table status; Array ( ) in backup_migrate_source_db_mysql->query() (line 370 of /opt/bitnami/apps/drupal/htdocs/sites/all/modules/backup_migrate/includes/sources.db.mysql.inc).

Why it uses ''@'%' and not the one in settings.php?

Any help for this? tried 7.x-2 and -3 yet i still have the same error.

Comments

scott.whittaker’s picture

I have the same error for a different column in a different table. It always errors out on the same table column, and happens when I try to create or edit a backup profile.

It's not doing this on the live site, though the test and live databases are on the same server with the same MYSQL user and same permissions. I've destroyed and re-created the database, restoring with a snapshot of the live database and get the same issue.

It kind of sounds like backup & migrate is attempting to access database tables as the anonymous user, and even though I've granted the anonymous user read permissions on the database (not sure if this is a good idea) I still get the error.

No idea what's going on here I'm afraid.

scott.whittaker’s picture

Actually Live and Test were running as different users, the odd thing is that Test (the one that wasn't working) was using the root user, so shouldn't have any issues.

Another weird thing is that while the Anonymous user was granted Global select privileges, I had to add database-specific select privileges for each database. That seemed to solve the issue.

Still not convinced that granting anonymous read access to the database is great for security though.

ronan’s picture

The module should be using the user specified in the settings file (or in the settings if you manually create a new source). It should not be attempting to access as anonymous and you don't need to add select access as anonymous (normally).

Is there something weird or different about how you are specifying the settings between the sites?

ronan’s picture

Also: are any of these tables actually views? Views are not used by a lot of modules but they're not currently supported by B&M. I ask because there's mention of views on this stackoverflow answer: http://stackoverflow.com/questions/6527599/mysql-forgets-who-is-logged-i...

ronan’s picture

Status: Active » Postponed (maintainer needs more info)
ibango’s picture

Issue summary: View changes

Hi,
I'm also having the same problem ("SELECT command denied to user ''@'localhost'") for a different column in a different table.
This started happening after a migration carried out by a third party (who unfortunatelly didn't use the Backup and migrate module for it) from a Windows server to a Linux (Ubuntu) server. The details in settings.php changed with the migration, but seem to be ok since there are no other DB related problems. Like acausing, I don't understand why B&M is trying to use ''@'localhost' instead of the user defined in settings.php (also, it tries to do the select in localhost, while the host in settings.php is not localhost) :S.

Any ideas?

retorque’s picture

A clarification for my future reference next time this problem tries to eat 3 hours (and maybe it will help someone else, since this seems to be the only related thread to appear in the issue queue):

This error occurred for me in Drupal 6 after a client moved a site to a new server. The site was using the Ubercart Views Marketing module, which creates MySQL views.

The link in comment #4 goes to a Stack Overflow thread explaining that views are created with a reference to the user account. If you move a database to a new server where the original account does not exist, backup_migrate is unable to populate the list of tables in a profile, and attempts to run a backup or edit a profile will generate this error (though in my case, it identified a specific username that was no longer in use rather than a blank username - likely a difference between the D6 and D7 versions). I suspect that the same issue could also occur if you create a new database on the same server and use a different username to access it, but I have not tested that.

I spent some time trying to remove and reinstall the Ubercart Views Marketing module before I figured out that the client had also not granted permissions to drop or create views. Once the user had the appropriate permissions, I removed the views, uninstalled, and reinstalled the Ubercart Views Marketing module, and Backup and Migrate started to work again.

couturier’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)