Notifications
Sign Up Sign In
Q&A

How to temporarily disable a MySQL user?

+1
−1

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?

Why should this post be closed?

2 comments

The title sounds like you want to disable a specific user, but the body sounds like you want to disable "everyone but me". Is the latter correct? ‭Monica Cellio‭ 23 days ago

@Monica I mean the solution works regardless of whether you are disabling a bunch or just one user ‭Charlie Brumbaugh‭ 22 days ago

2 answers

+3
−1

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 comments

+1
−0

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.

0 comments

Sign up to answer this question »