Removing users in MySQL

As with creating databases and tables, the opposite of creating a user is to DROP. As we shall see, removing a user does not revert any changes that they have made to the database(s) to which they had access. If a user had the ability to create users, removing them will not remove the users they created.

Unlike databases and tables, dropping a user requires that you also specify the hostname of the user's record. Therefore, one cannot always enter:

DROP USER exemplar;

This will only work if the user was created without specifying the hostname.

If it exists, one must include the hostname. For best practice, the basic syntax is:

DROP USER <userid>@<hostname>;

Therefore to drop user exemplar, we would pass the following statement: ...

Get MySQL for Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.