3

How do I give a user access to specific tables within a MySQL database?

2 Answers 2

7
grant select on table to username
Sign up to request clarification or add additional context in comments.

3 Comments

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.
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.
log in as the username user - then select from the table - you should not get any exception
0

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

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."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.