Allow a user to view stored procedures created by other users

Asked

Viewed 1,825 times

2

I have a Mysql database populated with some stored procedures. The problem is that two different users have created several procedures, so that only the user who created the stored Procedure can see its content. Within this context, I would like all two users to be able to see all the procedures, that is, the ones he created and the others created by the other user.

How could this be possible?

1 answer

2


You need to give permission (or privilege) EXECUTE for both users, about the procedures each other’s.

The command GRANT can be executed in a way to give permissions to execute any routines of a database.

Example:

GRANT EXECUTE ON banco.* TO 'usuario'@'host';

Also, so a user can see the code of a Procedure created by another, he needs the privilege SELECT on the table mysql.proc. This can be conformed in the command documentation SHOW PROCEDURE CODE.

In short, the listing of objects in a database or code of one of them is not always done through permissions directly related to the object. So check the privileges as SELECT in the Mysql control tables and in the tables of the current database.

  • It didn’t work, my user still doesn’t see the other user’s permissions. Funny that I did this test on localhost and users are able to view it quietly, but in production are no longer.

  • @mayconfsbrito I don’t know if I get it. View permissions? What exactly is the goal? List procedures? View source code? Run them? Something that usually causes problems is in relation to host informed in command grant. You must inform the host on which the user logs in and not the host on which the server is. Mysql. Another thing is that there may be a lack of another privilege for the user to simply list the information of the other. Also try to add the privilege SELECT.

  • I am not being able to view the source code of the procedures created by the other user, even if my user is super administrator of the database, that is, have permission for everything, including Grant. When running Grant I have replaced localhost with '%', ie 'user'@'%'.

  • @mayconfsbrite If an administrator is not allowed to see, then there is a problem with the environment. Tried to restart the Mysql instance?

  • @etluiz not, because this server is running in production environment, would have to be performed at another time. You believe that restarting the mysql service could disappear with this problem?

  • @etluiz thanks to your suggestion to allow SELECT privileges the problem has been solved. Please edit your reply stating the granting of permission through SELECT so I can rate it as correct.

  • @mayconfsbrito Glad you decided! I updated the answer.

  • thank you very much.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.