Skip to main content
St Louis

Back to all posts

How to Revoke Privileges From A MySQL User?

Published on
4 min read
How to Revoke Privileges From A MySQL User? image

Best MySQL Management Tools to Buy in December 2025

1 SQL: Learn SQL (using MySQL) in One Day and Learn It Well. SQL for Beginners with Hands-on Project. (Learn Coding Fast with Hands-On Project Book 5)

SQL: Learn SQL (using MySQL) in One Day and Learn It Well. SQL for Beginners with Hands-on Project. (Learn Coding Fast with Hands-On Project Book 5)

BUY & SAVE
$3.99
SQL: Learn SQL (using MySQL) in One Day and Learn It Well. SQL for Beginners with Hands-on Project. (Learn Coding Fast with Hands-On Project Book 5)
2 High Performance MySQL

High Performance MySQL

  • QUALITY ASSURANCE: CAREFULLY VETTED FOR READABILITY AND QUALITY.
  • ECO-FRIENDLY CHOICE: SAVE MONEY WHILE PROMOTING SUSTAINABILITY.
  • UNIQUE TITLES: DISCOVER HARD-TO-FIND BOOKS AT GREAT PRICES.
BUY & SAVE
$50.00
High Performance MySQL
3 MySQL Cookbook: Solutions for Database Developers and Administrators

MySQL Cookbook: Solutions for Database Developers and Administrators

BUY & SAVE
$56.73 $89.99
Save 37%
MySQL Cookbook: Solutions for Database Developers and Administrators
4 MySQL High Availability: Tools for Building Robust Data Centers

MySQL High Availability: Tools for Building Robust Data Centers

BUY & SAVE
$42.99
MySQL High Availability: Tools for Building Robust Data Centers
5 MySQL Crash Course

MySQL Crash Course

BUY & SAVE
$15.81 $34.99
Save 55%
MySQL Crash Course
6 Linux Server Hacks: 100 Industrial-Strength Tips and Tools

Linux Server Hacks: 100 Industrial-Strength Tips and Tools

  • AFFORDABLE PRICES ON QUALITY USED BOOKS FOR SAVVY READERS.
  • THOROUGHLY INSPECTED FOR GOOD CONDITION; GREAT VALUE GUARANTEED!
  • ECO-FRIENDLY CHOICE: SUPPORT RECYCLING WHILE ENJOYING GREAT READS.
BUY & SAVE
$12.79 $24.95
Save 49%
Linux Server Hacks: 100 Industrial-Strength Tips and Tools
7 Learn SQL by Examples: Examples of SQL Queries and Stored Procedures for MySQL and Oracle

Learn SQL by Examples: Examples of SQL Queries and Stored Procedures for MySQL and Oracle

BUY & SAVE
$11.99
Learn SQL by Examples: Examples of SQL Queries and Stored Procedures for MySQL and Oracle
8 SQL Hacks: Tips & Tools for Digging Into Your Data

SQL Hacks: Tips & Tools for Digging Into Your Data

  • AFFORDABLE LEARNING: QUALITY BOOKS AT BUDGET-FRIENDLY PRICES!
  • ECO-FRIENDLY CHOICE: SUPPORT SUSTAINABILITY WITH PRE-OWNED TITLES.
  • UNIQUE FINDS: DISCOVER RARE GEMS AND CLASSIC READS IN GOOD SHAPE!
BUY & SAVE
$25.05 $29.99
Save 16%
SQL Hacks: Tips & Tools for Digging Into Your Data
9 Mastering MySQL: The Complete Guide to Database Management and Optimization: From Beginner to Advanced SQL Queries, Database Design, and Performance ... From Beginner to Full-Stack Mastery Book 5)

Mastering MySQL: The Complete Guide to Database Management and Optimization: From Beginner to Advanced SQL Queries, Database Design, and Performance ... From Beginner to Full-Stack Mastery Book 5)

BUY & SAVE
$4.99
Mastering MySQL: The Complete Guide to Database Management and Optimization: From Beginner to Advanced SQL Queries, Database Design, and Performance ... From Beginner to Full-Stack Mastery Book 5)
10 Murach's MySQL

Murach's MySQL

  • MASTER ESSENTIAL SQL STATEMENTS FOR EFFECTIVE MYSQL DATABASE MANAGEMENT.
  • BUILD ROBUST DATABASES WITH PRACTICAL CODING EXAMPLES THROUGHOUT THE BOOK.
  • BOOST YOUR SKILLS AND CONFIDENCE IN SQL FOR REAL-WORLD APPLICATIONS!
BUY & SAVE
$73.88
Murach's MySQL
+
ONE MORE?

To revoke privileges from a MySQL user, you can use the REVOKE statement followed by the specific privileges you want to revoke and the name of the user or users from whom you want to revoke the privileges. For example, if you want to revoke all privileges from a user named 'test_user', you would use the following command: REVOKE ALL PRIVILEGES ON . FROM 'test_user'@'localhost'; This will revoke all privileges from the user 'test_user' on all databases and tables. Be sure to replace 'test_user' with the actual username you want to revoke privileges from.

How to revoke privileges from a MySQL user using the REVOKE statement?

To revoke privileges from a MySQL user, you can use the REVOKE statement followed by the specific privileges you want to revoke from the user.

Here is the basic syntax for revoking privileges from a user in MySQL:

REVOKE privilege_type ON database_name.table_name FROM 'username'@'host';

Replace privilege_type with the specific privileges you want to revoke, such as SELECT, INSERT, UPDATE, DELETE, etc. Replace database_name.table_name with the name of the database and table you want to revoke privileges from. Replace 'username'@'host' with the username and host for the user you want to revoke privileges from.

For example, to revoke the SELECT privilege on a specific table from a user, you would use the following command:

REVOKE SELECT ON database_name.table_name FROM 'username'@'host';

You can also revoke multiple privileges at once by listing them separated by commas in the REVOKE statement.

What is the syntax for revoking privileges from a MySQL user?

To revoke privileges from a MySQL user, you can use the following syntax:

REVOKE [privilege_type1, privilege_type2, ...] ON database_name.table_name FROM 'username'@'host';

For example, to revoke all privileges from a user named 'john' on all tables in a database named 'exampledb', the syntax would be:

REVOKE ALL PRIVILEGES ON exampledb.* FROM 'john'@'localhost';

You can also specify specific privileges to revoke by replacing ALL PRIVILEGES with specific privilege types like SELECT, INSERT, UPDATE, DELETE, etc.

How to revoke all privileges from all MySQL users except for the root user?

To revoke all privileges from all MySQL users except for the root user, you can use the following SQL query:

  1. Connect to the MySQL server using the root user:

mysql -u root -p

  1. Run the following SQL query to revoke all privileges from all users except for the root user:

SELECT CONCAT('REVOKE ALL PRIVILEGES ON ', user, '@', host, '.* FROM ', user, '@', host, ';' ) AS revokeQuery FROM mysql.user WHERE user <> 'root' AND host <> 'localhost';

  1. Copy the output of the query and paste it back into the MySQL command line to execute the revoke queries:

REVOKE ALL PRIVILEGES ON user1@hostname.* FROM user1@hostname; REVOKE ALL PRIVILEGES ON user2@hostname.* FROM user2@hostname; ...

  1. Finally, run the FLUSH PRIVILEGES command to apply the changes:

FLUSH PRIVILEGES;

This will revoke all privileges from all MySQL users except for the root user.

How to remove specific privileges from a MySQL user?

To remove specific privileges from a MySQL user, you can use the REVOKE statement. Here is an example of how to remove the SELECT privilege from a user named 'user1' on a database named 'database1':

  1. Connect to your MySQL server using the MySQL command-line tool or a MySQL client.
  2. Run the following command to revoke the SELECT privilege from the user 'user1' on the database 'database1':

REVOKE SELECT ON database1.* FROM 'user1'@'localhost';

This command will remove the SELECT privilege from the user 'user1' for all tables in the 'database1' database.

  1. You can also revoke other privileges by using the same REVOKE statement with the appropriate privilege(s) (e.g., INSERT, UPDATE, DELETE, etc.) and specifying the specific tables or databases as needed.

After running the REVOKE statement, the specified privileges will be removed from the user and they will no longer have permission to perform the revoked actions on the specified database or tables.

How to revoke privileges from a MySQL user without restarting the server?

You can revoke privileges from a MySQL user without restarting the server by using the REVOKE statement in MySQL.

Here's the general syntax for revoking privileges from a user:

REVOKE privilege_type ON database_name.table_name FROM 'username'@'hostname';

For example, if you want to revoke all privileges from a user named 'john' on all tables in a database named 'mydatabase', you would use the following command:

REVOKE ALL PRIVILEGES ON mydatabase.* FROM 'john'@'localhost';

After running the REVOKE statement, you may also need to flush the privileges to ensure that the changes take effect immediately:

FLUSH PRIVILEGES;

Once you have revoked the privileges from the user, they will no longer have access to the specified database or tables.