CREATE USER 'username'@'localhost' IDENTIFIED BY 'Password';
GRANT SELECT ON `databasename`.* TO 'username'@'localhost';
-
6What is the issue? and what is the question?Akina– Akina2021-12-28 05:18:43 +00:00Commented Dec 28, 2021 at 5:18
-
Such a confusing way to begin this question...El-– El-2024-10-15 19:33:27 +00:00Commented Oct 15, 2024 at 19:33
3 Answers
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
Comments
Try this
> GRANT SELECT, SHOW VIEW ON databasename.* TO 'username'@'localhost' IDENTIFIED BY 'password';
> FLUSH PRIVILEGES;
1 Comment
CREATE USER command, and then grant privileges to it, like @Mohammed Noor Alam did in his answer.