How to grant only few previleges ( to execute only DML and DDL statements) to the new user in MySQL ?
I tried the below command :
GRANT CREATE, ALTER, DROP, SELECT, INSERT, UPDATE, DELETE ON database.* to 'karthik' identified by 'shimoga';
But, it is showing Syntax error.
You need to take out identified by 'shimoga' from your statement.
CREATE USER:
CREATE USER 'karthik'@'instance' IDENTIFIED BY 'Password';
THEN GRANT Privileges:
GRANT SELECT, DELETE, UPDATE, EXECUTE, INSERT, DROP, ALTER, CREATE ON databaseName.* TO 'karthik'@'instancename';
Better Solution will be to create a Role. And assign the role to user. This will make your job easier if you have many users that needs similar privileges.
First Create a Role:
CREATE ROLE IF NOT EXISTS 'Developer'@'localhost';
Then Assign the required Privileges to the Role.
GRANT SELECT, DELETE, UPDATE, EXECUTE, INSERT, DROP, ALTER ON databaseName.* TO 'Developer'@'instanceName';
Finally Assign the Role to User which you would have already created:
GRANT 'Developer'@'localhost' TO 'karthik'@'instanceName';
SET DEFAULT ROLE ALL TO 'karthik'@'instanceName';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.