How do I give a user access to specific tables within a MySQL database?
2 Answers
grant select on table to username
3 Comments
Jonathon
This does not seem to specify what schema that "table" is in. I do not see how this would work if it does not do this.
Jonathon
priv_level: * | . | db_name.* | db_name.tbl_name | tbl_name | db_name.routine_name So I guess not in some situations, but more correctly for all situations "db_name.tbl_name" would work best here.
Randy
log in as the username user - then select from the table - you should not get any exception
Find the below example, Modify it according to your needs.
GRANT SELECT ON db_base.* TO db_user@'localhost' IDENTIFIED BY 'db_passwd';
1 Comment
Jonathon
The IDENTIFIED is used to create a new user, or to reset the password of a user. I would suggest not using it unless you are specifically trying to create a new user. "When the IDENTIFIED BY clause is present and you have global grant privileges, the password becomes the new password for the account, even if the account exists and already has a password. With no IDENTIFIED BY clause, the account password remains unchanged."