1

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';

1
  • Is this just a straight insert or an insert on duplicate key update?
    – atxdba
    Commented Sep 27, 2011 at 13:17

1 Answer 1

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

1
  • Seems good to me, +1 !!! Commented Sep 27, 2011 at 2:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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