How to delete or remove a MySQL/MariaDB user account on Linux/Unix

‮ual.www‬tturi.com
How to delete or remove a MySQL/MariaDB user account on Linux/Unix

To delete or remove a MySQL or MariaDB user account on Linux or Unix, you can use the DROP USER command.

Here is an example of how to delete a user called user1:

DROP USER 'user1'@'localhost';

This will delete the user user1 from the MySQL or MariaDB server.

If the user has been granted privileges on any databases or tables, you will need to revoke those privileges before deleting the user. You can use the REVOKE command to revoke privileges, like this:

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user1'@'localhost';

This will revoke all privileges and the grant option from the user user1.

Note that deleting a user will also delete any objects (such as tables or views) that the user has created, unless those objects have been granted to another user. Make sure you do not delete a user that is still being used by any objects on the server.

Created Time:2017-10-28 21:39:02  Author:lautturi