Search code examples
mysqlsql-grant

How to grant execution permission on procedure to ALL USERS


I need to grant all users with execution permissions to execute myprocedure

I'm using this:

grant execute on procedure myprocedure to '*'@'%%';

And I got this:

SQL Error [1410] [42000]: You are not allowed to create a user with GRANT

I also tried to create it with root user, but it didn't work:

mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> grant execute on procedure myprocedure to '*'@'%%';
ERROR 1410 (42000): You are not allowed to create a user with GRANT
mysql>

Any idea?


Solution

  • https://dev.mysql.com/doc/refman/en/grant.html says:

    MySQL does not support wildcards in user names.

    (emphasis is theirs)

    Users don't get privileges implicitly when they are created.

    You must grant privileges to each user explicitly as they are created.

    This is a good thing for the sake of security. It would be a bad strategy if users gained privileges that you didn't intend them to have, just because someone set up a GRANT with a wildcard.