0

I try to give rights for a database to existing database. I am logged in as root (btw. the whole Database setup is quite difficult on a Kubernetes Cluster and the queries run on a poststart lifecycle hook)

mysql> GRANT ALL ON grafana.* TO 'testdb'@'localhost';
Query OK, 0 rows affected, 1 warning (0.02 sec)

This works, but it won´t allow another container access the database, I get an Access denied error.

mysql> GRANT ALL ON grafana.* TO 'testdb'@'%';
ERROR 1410 (42000): You are not allowed to create a user with GRANT

This is what I desire as a query, but I it seems I am not allowed to do that.

I tried to get it done with the following workaround:

RENAME USER 'testdb'@'localhost' TO 'testdb'@'%';

This actually seems to work, but I feel like I miss something logically. Is that valid or am I overlooking something? Or should I fix my second command? If yes, how would I do that?

Shadow
  • 32,277
  • 10
  • 49
  • 61
Data Mastery
  • 989
  • 3
  • 11
  • 31
  • 1
    Although both of the first two commands are working on users you perceive to be named as `testdb`, they're actually held as different users, each with different permissions. As such, the error it telling you that the user `'testdb'@'%'` doesn't exist at the time you try to grant it permissions. So, either run the `rename` first, or create the user `'testdb'@'%'` first. – MatBailie Oct 05 '21 at 15:13
  • thank you, that helps a lot – Data Mastery Oct 05 '21 at 15:24

0 Answers0