Forums

[MySQL] Granting user privileges on db

Hi, for the past 10 days or so, the cronjob that backs up our MySQL db and archives it has failed at the dbbackup/mysqldump step, with this error (redacted):

CommandConnectorError: Error running:  mysqldump username$db --quick --host=username.mysql.pythonanywhere-services.com --user=username --password=pwd 
mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces

If I try to grant privileges to the user username with something like:

GRANT ALL PRIVILEGES ON username$db . * TO 'username'@'username.mysql.pythonanywhere-services.com';

I get

ERROR 1045 (28000): Access denied for user 'username'@'%' (using password: YES)

Some information on the web suggests that this issue is due to a recent MySQL update. Regardless, why doesn't the user that's supposedly the owner of the db have these privileges, and why can't I grant those privileges (at least PROCESS) when I'm logged in as that user? Does anyone know the correct command for this? Thanks.

You should use --no-tablespaces option in the command, see the full help page. You can't grant privileges because you're on a shared server.

Thanks for that. I did see that solution in various places but some people complained that they needed tablespaces. I actually don't know if I do, but I'll try it and hopefully it won't break something else.

As I'm using Django, I can't add the --no-tablespaces option directly, and instead need to add it to the DUMP_SUFFIX parameter under DBBACKUP_CONNECTORS in the settings, as described here:

https://github.com/jazzband/django-dbbackup/issues/395

Unfortunately, I tried adding --no-tablespaces and am getting the same error:

mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces

Do you use all the flags that are in the example on the help page that Piotr linked to?

Yes, I tried with both -set-gtid-purged=OFF --no-tablespaces and --set-gtid-purged=OFF --no-tablespaces --column-statistics=0 as DUMP_SUFFIX, with no luck. However, I've just tried mysqldump directly with all three options (the first two alone didn't work), and the backup succeeded.

I'm going to switch to mysqldump instead of Django's dbbackup and see if the backup workflow works again.

Thanks for the help, @pafk and @fjl.

Glad to hear that you made it work!