Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
How to temporarily disable a MySQL user?
Sometimes I will need to temporarily lock out other MySQL users when I am making large structure changes and want to make sure that nobody else is inputting or changing the data. The other use case is temporarily locking out a single user if you are sure if that user is being used anymore.
How can I do this without changing the passwords or permissions?
2 answers
I think the closest thing to what the post body is suggesting is offline mode:
- Connected client users who do not have the SUPER privilege are disconnected on the next request, with an appropriate error. Disconnection includes terminating running statements and releasing locks. Such clients also cannot initiate new connections, and receive an appropriate error.
- Connected client users who have the SUPER privilege are not disconnected, and can initiate new connections to manage the server.
To put a server in offline mode, change the value of the offline_mode system variable from OFF to ON. To resume normal operations, change offline_mode from ON to OFF.
0 comment threads
The easiest way to temporarily disable a MySQL user is to the change the value of the Host column in the mysql.user table to an invalid host.
UPDATE mysql.user SET HOST = 'blocked' WHERE #your condition here
To do this through MySQLWorkbench,
- go to Management
- Users and Privileges
- Click on the user name
- set the 'Limit to Hosts Matching:' field to 'blocked'.
This makes the user unable to connect and is easily reversed.
1 comment thread