mariadb drop user "wildcard"
suppose i create these two users:
CREATE USER 'ILOVEMARIADB'@'126.96.36.199' ; CREATE USER 'ILOVEMARIADB'@'188.8.131.52' ;
is there any way to delete BOTH of these in one statement?
i tried these:
DROP USER 'ILOVEMARIADB' ; DROP USER 'ILOVEMARIADB'@%' ; DROP USER 'ILOVEMARIADB'@_' ;
EDIT: doing this seems to case me problems later on when i try to add the same name using a different IP number.:
DELETE FROM mysql.user WHERE User = "ILOVEMARIADB" AND Host != 'localhost' ;
Answer Answered by Ian Gilfillan in this comment.
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;
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.