I want to create two users in my test MySQL database, one with read-only access to tables related to report generation, etc., and the other with read and write access to the same tables. This is for testing a subsystem that usually connects to a read-only user, but switches to a read and write user for specific tasks. I created a user to read and write with the correct privileges, and now I need the read-only version of the same user.
I would prefer not to create a read-only version from scratch, since I had to set many privileges, which was quite difficult. Is there a way to create a new user based on an existing user and then remove the INSERT / UPDATE / DELETE privileges from the new user? Something like CREATE USER 'user2' LIKE 'user1' or similar? I could not find it in MySQL docs if possible.
source share