I have a database with hundreds of active connections at any point in time. When I use the DROP USER sql statement to remove a user account, it takes ~4 seconds, during which all other connections have the state "Checking permissions". This means that to delete 1000 users, I'll effectively be locking the database for a good part of 4000 seconds, which is unacceptable. I do notice, however, that deleting a user row from the mysql.users table is instant.
Is deleting a row from mysql.users kosher? What are the drawbacks compared to using DROP USER? Am I leaving stale rows elsewhere? Are there propagation issues? I'm most likely going to have to go this route, but I want to know what other clean up I'll need to do.
To delete rows in a MySQL table, use the DELETE FROM statement: DELETE FROM products WHERE product_id=1; The WHERE clause is optional, but you'll usually want it, unless you really want to delete every row from the table.
To use DROP USER , you must have the global CREATE USER privilege, or the DELETE privilege for the mysql system database. When the read_only system variable is enabled, DROP USER additionally requires the SUPER privilege. Each account name uses the format described in Section 6.2. 4, “Specifying Account Names”.
The DROP USER statement is used to remove a user from the SQL Server database.
Depends on your version of MySQL
Drop user in MySQL <= v5.0
only removed the user record but not privileges.
MySQL >= v5.0.2
does both in a single go.
Also multiple users can be passed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With