How to Revoke Privileges in MySQL
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
If you’re a database administrator for MySQL, you probably want to remove user access rights to database objects from time to time. This guide covers how to do so.
MySQL manages access through a set of privileges that define what a user can and cannot do. These privileges include actions like SELECT, INSERT, UPDATE, DELETE, and more, applicable at different levels such as global, database, table, column, or routine.
Before revoking privileges, use the SHOW GRANTS command to review a user’s current privileges.
SHOW GRANTS FOR 'username'@'host';
Replace username and host with the specific user account and host details.
To revoke global privileges, use the REVOKE statement. Global privileges are revoked from the mysql.user table.
REVOKE ALL PRIVILEGES ON *.* FROM 'username'@'host';
Database-level privileges are revoked from the mysql.db table. Specify the database name in the query.
REVOKE ALL PRIVILEGES ON `database_name`.* FROM 'username'@'host';
To remove privileges on a specific table, mention the database and table name.
REVOKE ALL PRIVILEGES ON `database_name`.`table_name` FROM 'username'@'host';
Column-level privileges are removed by specifying the database, table, and column.
REVOKE ALL PRIVILEGES ON `database_name`.`table_name`(`column_name`) FROM 'username'@'host';
For stored routines like procedures and functions, specify the routine type and name.
REVOKE EXECUTE ON PROCEDURE `database_name`.`procedure_name` FROM 'username'@'host';
After revoking privileges, run the FLUSH PRIVILEGES command to reload the privilege tables and apply changes immediately.
FLUSH PRIVILEGES;
Regularly monitor user privileges and adjust them as needed. This ensures that users have only the necessary privileges, enhancing database security.
For access management workflows, Basedash complements SQL controls with governed reporting, shared visibility, and AI-assisted analysis so teams can monitor permission changes without losing auditability.
Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.