MariaDB removes a user with the DROP USER statement, which deletes one or more account entries from the mysql system tables so those accounts can no longer authenticate. For the usual case, the command is simply DROP USER 'username'@'host';, run by an account with the global CREATE USER privilege (part of the ADMIN role in current versions) and the DELETE privilege on the mysql database. Removal is permanent and immediate for new connections, but the statement only deletes the user account itself; it does not quietly revoke every grant recorded for that account, does not change the ownership of any database objects, and does not terminate sessions that are already connected. Each of those points is where people get surprised.

What the statement actually does

A MariaDB user account is an entry in the mysql.user table, identified by a pair of values: the user name and the host from which the user may connect. 'alice'@'localhost' and 'alice'@'%' are two different accounts with potentially different passwords and privileges. DROP USER deletes the account entry or entries you name. Once removed, authentication against that account fails, so no new session can be opened with it.

The basic forms:

IF EXISTS suppresses the error that would otherwise occur when the named account does not exist, which is useful in deployment scripts that must be idempotent. DROP USER is also the more precise successor to the older DROP USER variants MariaDB inherited from MySQL; you do not need to delete rows from mysql.user by hand and should not do so while the server is running, because the grant tables can become inconsistent with memory.

Privileges for the operation: in MariaDB, an administrative user typically holds the CREATE USER privilege globally, which governs creating, altering, renaming, and dropping accounts, together with DELETE on the mysql database. The ADMIN role bundles the privileges needed to manage users and grants. Ordinary users cannot drop other accounts, and a user generally cannot drop an account that is more privileged than their own.

Removing the right account: host matters

The single most common mistake is dropping the wrong account or believing a user is gone when a second account with the same name remains. MariaDB matches host patterns in the account name, so 'alice'@'%' is a distinct account from 'alice'@'localhost'. Many setups create both: a local account for administration and a wildcard account for remote application servers. Dropping one leaves the other working perfectly, which can look like the drop failed.

Before dropping anything, list what exists:

Then drop exactly the account or accounts you intend. If you want to retire a user across every source host, drop each entry explicitly:

MariaDB also permits wildcard host matching in the account name, and there are _ and % patterns as in GRANT. Be deliberate here: a pattern is a convenience for scripts, but it can match accounts you did not think about. When in doubt, enumerate.

Cleanup that DROP USER does not perform

Removing the account stops future logins but leaves two categories of residue that administrators often need to address separately.

Privilege records. MariaDB records privileges both in the mysql.user row for global privileges and in mysql.db, mysql.tables_priv, mysql.columns_priv, and mysql.procs_priv for finer-grained grants. DROP USER removes the account row, and with it the account's global privileges; if an orphaned grant row in one of the other privilege tables still names that user and host, it no longer corresponds to a valid account and is effectively inert, because authentication cannot succeed in the first place. MariaDB keeps grant tables internally consistent as you use the SQL statements, so the practical guidance is to use the SQL statements rather than editing tables, and if you are investigating odd leftover grants, review the privilege tables with SHOW GRANTS before the drop and inspect them afterward if something looks wrong.

Database objects owned by the user. DROP USER does not drop databases, tables, views, stored routines, or events created by the user, and MariaDB's privilege model generally does not have a concept of object ownership the way some other database systems do. Objects persist; they simply become unreachable by that account. If the departing user's objects should be reassigned, that is a separate migration step: GRANT the necessary privileges to the replacement account, or have an administrator recreate them.

Definer clauses on routines, views, and triggers. This is the subtle one. Stored procedures, functions, views, triggers, and events can carry a DEFINER clause naming the account that created them, for example DEFINER='alice'@'localhost'. If you drop alice, those objects remain but their definer references a nonexistent account. Depending on the object and how it is invoked, this can produce errors or warnings about an unknown definer, or privileges that behave unexpectedly. MariaDB documentation and practitioners routinely note that SHOW GRANTS and object listings should be reviewed before dropping an account that created routines or views. The fix is to recreate the object with a new DEFINER (or alter it, where supported) before or after dropping the account; that is a distinct maintenance task, not part of DROP USER.

Active sessions. A logged-in session is not closed by DROP USER. Existing connections continue until they disconnect or you terminate them. If you need the account's access cut immediately, find the connection IDs and terminate them:

MariaDB does not automatically kill sessions belonging to a dropped account for most connection types; the account simply cannot open new ones. The exception worth knowing is accounts dropped while connected through the server's account-management paths themselves; the general rule to plan around is that existing sessions persist.

The IF EXISTS behavior and errors to expect

Without IF EXISTS, dropping a nonexistent account raises an error such as ERROR 1396 (HY000): Operation DROP USER failed for 'alice'@'localhost'. That is not a bug; it is the statement telling you the named account was not found, which often means the host part did not match what you supplied. Scripts that must run repeatedly should use IF EXISTS, and scripts that must guarantee removal should inspect the affected-rows count reported by the client after the statement, because IF EXISTS will happily succeed even when nothing was removed.

A second common error class is privilege-related: ERROR 1227 (42000): Access denied; you need the CREATE USER privilege for this operation. The fix is to run the statement as an administrative account, not to edit the grant tables as a workaround.

What "remove a user" might also mean

The search phrase covers two related tasks, and it is worth separating them, because the SQL differs.

Removing the account entirely. This is DROP USER, described above: the account ceases to exist and cannot log in.

Removing privileges but keeping the account. If the goal is to strip access without deleting the account (for example, suspending a contractor), use REVOKE. REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'alice'@'localhost'; removes all privileges and removes the ability to grant privileges to others, but the account row remains and the user can still connect, assuming the account has a password and the server does not otherwise restrict login. To also prevent login while keeping the account, a common pattern is to lock it with ALTER USER 'alice'@'localhost' ACCOUNT LOCK; (older installations may rely on ALTER USER ... PASSWORD = PASSWORD(...) with an unusable password instead). Choose based on intent: DROP USER for permanent removal, REVOKE/ACCOUNT LOCK for temporary or reversible measures. A third case is renaming rather than removing, which is RENAME USER 'old'@'host' TO 'new'@'host'; and preserves the account's privileges.

Efficiency for bulk removal and automation

For a handful of users, individual DROP USER statements are clearest. For larger cleanups, MariaDB supports multiple accounts in one statement, which is generally preferable to scripting one round trip per account. When generating statements programmatically, build them from the authoritative list in mysql.user rather than from a guessed host pattern, and always include the host portion verbatim.

A defensive workflow looks like this:

1: Snapshot who the account is and what it can do: SHOW GRANTS FOR 'alice'@'%'; plus SELECT User, Host FROM mysql.user WHERE User = 'alice';. 2: Identify objects referencing the account as definer, and decide whether they need altering. 3: Terminate the account's active sessions if immediate cutoff is required. 4: Run DROP USER for each matching account, ideally in one statement. 5: Verify with the same mysql.user query; the result should be empty for that user. 6: If applicable, fix orphaned definers and reassign object ownership.

Back up the mysql database (or at least the grant tables) before systematic user cleanup on a production server, since the operation is not reversible. Accounts are easy to recreate from a script; a botched privilege landscape is not.

Practical cautions

Dropping an account that a running application uses will cause the application to fail to reconnect, typically with Access denied for user 'alice'@'host' errors, but the failures may appear gradually as pooled connections are recycled, which can be confusing in the middle of a maintenance window. Coordinate with whatever the account serves. Also be careful with wildcard accounts in shared-hosting-style setups: '%' accounts often serve many clients, and "removing a user" by pattern can remove more than intended.

Finally, prefer the SQL statements over direct DELETE and INSERT against mysql.user. MariaDB's user-management statements keep the in-memory privilege structures and the tables synchronized, and direct manipulation while the server is running risks a restart to reconcile the two, or worse, an inconsistent state that leaves accounts active or grants unusable. If direct table surgery is ever necessary in an emergency, do it with the server stopped, and follow it with a straight reload of the grant tables on startup; that is a recovery technique, not a routine procedure.

In short: DROP USER 'name'@'host' is the removal mechanism, host matching decides which account actually disappears, IF EXISTS makes scripts repeatable, and the follow-up work—session termination, definer fixes, and object reassignment—is the part that determines whether the user is truly gone from the system's practical operation, not just from its grant tables.