-1

There are five table in my database, now I create user1 , but I want this come true:

user1 only can read current five table.

user1 can create table, and insert & update to new table.

How can I accomplish this?

Scath
  • 3,777
  • 10
  • 29
  • 40

1 Answers1

0

You should think about:

GRANT ALL PRIVILEGES ON your_db_name.table_1 to 'your_user_name'@'%';
GRANT ALL PRIVILEGES ON your_db_name.table_2 to 'your_user_name'@'%';
GRANT ALL PRIVILEGES ON your_db_name.table_3 to 'your_user_name'@'%';
GRANT ALL PRIVILEGES ON your_db_name.table_4 to 'your_user_name'@'%';
GRANT ALL PRIVILEGES ON your_db_name.table_5 to 'your_user_name'@'%';

Till now your_user_name has access to this five tables only. Below Grant will allow to CREATE table in specified DB to "user_name"

GRANT CREATE ON db_name.* TO 'user_name'@'%';

Once the user created tables, then you have to update the permission as required.

GRANT CREATE ON db_name.* TO 'user_name'@'%';
GRANT SELECT, INSERT, UPDATE ON db_name.table_1 TO 'user_name'@'%';
GRANT SELECT, INSERT, UPDATE ON db_name.table_2 TO 'user_name'@'%';