Search code examples
mysqlsqlsql-drop

Difference between DROP USER and deleting a row from the mysql.user table


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.


Solution

  • 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.