Is there a way to perform a DROP at specific prefix users (lets say tenant_* ) of MySQL?
IE :
DROP USER 'tenant_george'@'%';
DROP USER 'tenant_john'@'%';
etc
Is there a way to perform a DROP at specific prefix users (lets say tenant_* ) of MySQL?
IE :
DROP USER 'tenant_george'@'%';
DROP USER 'tenant_john'@'%';
etc
2
Answers
I don’t think that is possible.
according to the doc to delete multiple users you need to so:
in your case, I would rather write a script that generates such line 😉
(edit: typo)
Create the drop statements using
Adjust the
WHERE
clause as needed (or simply ignore some of the output.)Then copy/paste the output to perform the DROPs.
(This could be turned into a stored proc, but, assuming it is a one-time task, I suggest including the manual step. And it gives you a chance to desk-check that you have not accidentally included ‘root’ or have quoting problems.)