Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql grant select privilege on only one table and some columns of it

I have a table with around 10 columns I have created a user with no privileges select.

Now I want it to grant only select privileges to only that table and if possible only 2-3 columns.

like image 215
Nik Avatar asked Mar 05 '14 03:03

Nik


People also ask

Is it possible to specify privileges per table in MySQL?

You can create a user with table level permissions in MySQL by performing the following: Connect to MySQL as a user with the Create_user_priv and Grant_priv. Determine which users have these privileges by running the following query. Your user will already need the SELECT privilege on MySQL.

How do I give access to a specific table in MySQL?

To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name. * TO 'username'@'localhost';

How do I grant multiple privileges in MySQL?

In this syntax: First, specify one or more privileges after the GRANT keyword. If you grant multiple privileges, you need to separate privileges by commas. Second, specify the privilege_level that determines the level to which the privileges apply.

How do I grant privileges to a table?

You can also grant one or more table privileges by specifying a privilege-list. Use the DELETE privilege type to grant permission to delete rows from the specified table. Use the INSERT privilege type to grant permission to insert rows into the specified table.


1 Answers

https://dev.mysql.com/doc/refman/5.1/en/grant.html#grant-column-privileges

GRANT SELECT (col1,col2) ON database.table TO 'someuser'@'localhost' IDENTIFIED BY 'password';
like image 81
J. A. Streich Avatar answered Sep 20 '22 17:09

J. A. Streich