MySQL Grant Permission

MySQLpermissions

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

Best Answer

'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