Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I want to Grant a user only INSERT permission.

When I try to insert data, it throws the error "Access Denied".

What permission do I give a user to use/select database in mysql and how?

I have given only GRANT INSERT ON database.* To user@'localhost';

share|improve this question
    
Is this just a straight insert or an insert on duplicate key update? –  atxdba Sep 27 '11 at 13:17
add comment

1 Answer 1

'insert' permission should be all you need to do an insert:

create database stack;
create user dummy;
create table stack.t(v integer primary key);
grant insert on stack.* to dummy;

as dummy:

insert into stack.t values(1);
Query OK, 1 row affected (0.00 sec)

select * from stack.t;
ERROR 1142 (42000): SELECT command denied to user 'dummy'@'localhost' for table 't'

and the grant like this will even apply to tables created after the grant was made - it gives a database privilege

As you also want to select you will also need to grantselecton stack.* to dummy

share|improve this answer
    
Seems good to me, +1 !!! –  RolandoMySQLDBA Sep 27 '11 at 2:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.