CREATE USER 'username'@'localhost' IDENTIFIED BY 'Password';
GRANT SELECT ON `databasename`.* TO 'username'@'localhost';
CodePudding user response:
Try this
> GRANT SELECT, SHOW VIEW ON databasename.* TO 'username'@'localhost' IDENTIFIED BY 'password';
> FLUSH PRIVILEGES;
CodePudding user response:
Create new user
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT type_of_permission ON database_name
GRANT SELECT ON database_name.table_name TO 'username'@'localhost';
Once you have finalized the permissions that you want to set up for your new users, always be sure to reload all the privileges.
FLUSH PRIVILEGES;
Here is a short list of other common possible permissions that can be used.
ALL PRIVILEGES- as we saw previously, this would allow a MySQL user full access to a designated database (or if no database is selected, global access across the system)
CREATE- allows them to create new tables or databases
DROP- allows them to them to delete tables or databases
DELETE- allows them to delete rows from tables
INSERT- allows them to insert rows into tables
SELECT- allows them to use the SELECT command to read through databases
UPDATE- allow them to update table rows
