mariadb drop user "wildcard"

You are viewing an old version of this question. View the current version here.

hello -

suppose i create these two users:

CREATE USER 'ILOVEMARIADB'@'123.123.123.123' ;
CREATE USER 'ILOVEMARIADB'@'234.234.234.234' ;

is there any way to delete BOTH of these in one statement?

i tried these:

DROP USER 'ILOVEMARIADB'   ;
DROP USER  'ILOVEMARIADB'@%'  ;
DROP USER  'ILOVEMARIADB'@_'  ;

no luck.

and doing this seems to case me problems when i try to add the same name using a different IP number.:

DELETE FROM mysql.user WHERE User = "MarkEdwards" AND Host != 'localhost' ;

Answer

It's not a one-liner, but perhaps something like this?

SELECT GROUP_CONCAT('\'',user, '\'@\'', host, '\'') INTO @accounts FROM mysql.user WHERE user = 'ILOVEMARIADB';
SET @accounts = CONCAT('DROP USER ', @accounts);
PREPARE s FROM @accounts;
EXECUTE s;

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.