mariadb drop user "wildcard"
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.
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.