Langdale Pikes
Langdale Pikes

Reputation: 61

MySQL User Privileges - Restrict Users to some tables

I have created a database with several tables, such as user, booking etc.

I have allocated privileges using the User tab within phpmyAdmin, wherein, Users are permitted View and Add privileges, Administrators have View, Add and Amend privileges and Managers have ALL privileges including Delete.

Using the MySQL database, is it possible to do some restrictions as below:

a) Restrict the User to View and Add to only certain tables.

b) Allow the User to view records solely for themselves and not those of any another user.

If so How?

Upvotes: 3

Views: 892

Answers (1)

Elumalai Kaliyaperumal
Elumalai Kaliyaperumal

Reputation: 1520

You can give privileges to some users to some tables using mysql GRANT as below

GRANT SELECT, INSERT, UPDATE ON db.booking TO 'someuser'@'somehost';

For all privileges use ALL instead of SELECT, UPDATE etc.

GRANT ALL ON db.booking TO 'someuser'@'somehost';

For documentation please go through mysql GRANT

Upvotes: 3

Related Questions