2023
How to create a read-only MySQL user?
62
Step 1. Open the workbench and log in as a MySQL administrator
Step 2. Create a new MySQL user account.
CREATE USER 'report'@'%' IDENTIFIED BY '12345';
The % in the command above means that the user report can be used to connect from any host. You can limit access by defining the host from where the user can connect. Omitting this information will only allow the user to connect from the same machine.
Step 4. Grant the SELECT privilege to the user.
GRANT SELECT ON DatabaseName.* TO 'report'@'%';
Step 5. After creating a new MySQL user account then you have to Connect to a Database with MySQL Workbench follow the link for "How to Connect to a Database with MySQL Workbench"
https://code2night.com/Blog/MyBlog/How-to-Connect-to-a-Database-with-MySQL-Workbench
Step 6. when we delete any record from the database we are getting error "delete from city where ID=1 Error Code: 1142. DELETE command denied to user 'report'@'localhost' for table 'city' 0.000 sec" because the user has only read-only permission