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.
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.
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';
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.
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.
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';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With