mariadb drop user "wildcard"
suppose i create these two users:
CREATE USER 'ILOVEMARIADB'@'188.8.131.52' ; CREATE USER 'ILOVEMARIADB'@'184.108.40.206' ;
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;