• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

How do I use GRANT in mysql to assign priviledges ?

Hello Guys,

I have a mysql database online. I have created a user for e.g. mysite_user1. This user is associated with 2 databases.

1. DBSet1  (has couple of tables)
2. DBSet2  (has one table)

Now for DBSet1, user1 has select priviledge only and for dbset2 user has several priviledges which I have assigned thru wizard.

I want to create a stored procedure in DBSet1 and want user1 to execute stored procedures. How can I grant priviledge so that it can execute any no. of stores procedure and maintain its current select only priviledge for database DBSet1.

I mean hwo can I achieve the following :

- Grant user1 to execute any no. of stores procedures in Dbset1.
- Grant user1 to execute only a particular stored procedure in DBSet1.
- Ensure that its previous priviledge is intact (Select).
- priviledge should be for all tables in DBSet1.

Can someone write sample grant statements to achieve the same.

(For info: if the stored procedure contains update statement for that db I hope it works).

I will be glad if anyone can help me out.

Thanks,

Cheers,
Saurabh
0
Sukhani
Asked:
Sukhani
  • 2
1 Solution
 
Varghese JacobCommented:
- Grant user1 to execute any no. of stores procedures in Dbset1.
GRANT EXECUTE ON Dbset1.* TO 'user1'@'localhost';

- Grant user1 to execute only a particular stored procedure in DBSet1.
GRANT EXECUTE ON DBSet1.sp_name TO 'user1'@'localhost';

- Ensure that its previous priviledge is intact (Select).
The above statements shouldn't meddle with select privilege

- priviledge should be for all tables in DBSet1.
What privilege?
0
 
SukhaniAuthor Commented:
I have given privilege to a particular mysql user. Inspite of that when I execute a stored procedure i get error Select command access denied for user xxx@ipaddress...
I did -
GRANT Execute on procedure 'test' for sitename_user;
GRANT Execute on procedure 'test' for sitename_user@'%';
When I do show grants for that user, i do see select, execute on procedure for that subroutine but thru .net connector when I execute that subroutine I am unsuccessful. What should I do ?
0
 
SukhaniAuthor Commented:
Solution could have been detailed.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now