patternsqlMinor
MySQL user permission on stored procedure
Viewed 0 times
storeduserpermissionproceduremysql
Problem
I've created a simple stored procedure:
But failed to run it:
Is it possible that my user name is an empty string? How do I create users and grant privileges? Can I grant a user all the privileges on all entities within a database?
mysql> CREATE FUNCTION hello (s CHAR(20))
-> RETURNS CHAR(50) DETERMINISTIC
-> RETURN CONCAT('Hello, ',s,'!');
Query OK, 0 rows affected, 1 warning (0.00 sec)But failed to run it:
mysql> SELECT hello('world');
ERROR 1370 (42000): execute command denied to user ''@'localhost' for routine 'test.hello'Is it possible that my user name is an empty string? How do I create users and grant privileges? Can I grant a user all the privileges on all entities within a database?
Solution
As the error message itself says that user do not have the execute permissions.
You need to grant the Execute Permission to that user.For that you need to login as root user and grant the permission as
For your other queries :
-
Yes It is possible that your username is an empty string but it is not safe to create the users like this.
-
For creating and granting privileges in brief have a look at This Link.
-
Yes you can grant all the privileges on all entities within a database.
for this you can execute a command like
Login as root user and issue a command
mysql> SELECT hello('world');
ERROR 1370 (42000): execute command denied to user ''@'localhost' for routine 'test.hello'You need to grant the Execute Permission to that user.For that you need to login as root user and grant the permission as
grant execute on db.* to user@localhost;For your other queries :
-
Yes It is possible that your username is an empty string but it is not safe to create the users like this.
-
For creating and granting privileges in brief have a look at This Link.
-
Yes you can grant all the privileges on all entities within a database.
for this you can execute a command like
Login as root user and issue a command
GRANT ALL ON DB_NAME.* TO 'USER'@'HOST' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;Code Snippets
mysql> SELECT hello('world');
ERROR 1370 (42000): execute command denied to user ''@'localhost' for routine 'test.hello'grant execute on db.* to user@localhost;GRANT ALL ON DB_NAME.* TO 'USER'@'HOST' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;Context
StackExchange Database Administrators Q#20221, answer score: 3
Revisions (0)
No revisions yet.