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 September 2025

1 High Performance MySQL

High Performance MySQL

  • QUALITY ASSURANCE: EACH BOOK GRADED 'GOOD' FOR RELIABILITY.
  • ECO-FRIENDLY CHOICE: SAVE MONEY AND THE PLANET WITH USED BOOKS.
  • DIVERSE SELECTION: ACCESS A WIDE RANGE OF GENRES AND TITLES.
BUY & SAVE
$50.00
High Performance MySQL
2 Head First PHP & MySQL: A Brain-Friendly Guide

Head First PHP & MySQL: A Brain-Friendly Guide

BUY & SAVE
$17.43 $54.99
Save 68%
Head First PHP & MySQL: A Brain-Friendly Guide
3 Murach's MySQL

Murach's MySQL

  • MASTER ESSENTIAL SQL STATEMENTS FOR EFFECTIVE DATABASE MANAGEMENT.
  • STEP-BY-STEP GUIDANCE FOR CREATING ROBUST MYSQL DATABASES.
  • PRACTICAL EXAMPLES TO BOOST YOUR CODING SKILLS AND CONFIDENCE.
BUY & SAVE
$76.60
Murach's MySQL
4 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 BUDGET-CONSCIOUS BUYERS.
  • ECO-FRIENDLY CHOICE: CONTRIBUTE TO SUSTAINABILITY BY REUSING BOOKS.
  • THOROUGHLY INSPECTED FOR QUALITY TO ENSURE A GREAT READING EXPERIENCE.
BUY & SAVE
$11.34 $24.95
Save 55%
Linux Server Hacks: 100 Industrial-Strength Tips and Tools
5 Learning PHP, MySQL & JavaScript: With jQuery, CSS & HTML5 (Learning PHP, MYSQL, Javascript, CSS & HTML5)

Learning PHP, MySQL & JavaScript: With jQuery, CSS & HTML5 (Learning PHP, MYSQL, Javascript, CSS & HTML5)

BUY & SAVE
$30.15 $49.99
Save 40%
Learning PHP, MySQL & JavaScript: With jQuery, CSS & HTML5 (Learning PHP, MYSQL, Javascript, CSS & HTML5)
6 AWS Lightsail setup, tricks and tools: DNS Zones, PHP, mySQL, SSL Cert, VHosts, metric, bots and all you need to succeed

AWS Lightsail setup, tricks and tools: DNS Zones, PHP, mySQL, SSL Cert, VHosts, metric, bots and all you need to succeed

BUY & SAVE
$9.99
AWS Lightsail setup, tricks and tools: DNS Zones, PHP, mySQL, SSL Cert, VHosts, metric, bots and all you need to succeed
7 Build a real Search Engine: Engineering tools: HTML, CSS, JavaScript, PHP, MySQL

Build a real Search Engine: Engineering tools: HTML, CSS, JavaScript, PHP, MySQL

BUY & SAVE
$19.90
Build a real Search Engine: Engineering tools: HTML, CSS, JavaScript, PHP, MySQL
8 MySQL Crash Course

MySQL Crash Course

BUY & SAVE
$20.00 $34.99
Save 43%
MySQL Crash Course
9 MySQL Cookbook

MySQL Cookbook

  • AFFORDABLE PRICES FOR QUALITY READS, SAVING YOU MONEY!
  • EACH BOOK IS INSPECTED TO ENSURE GOOD CONDITION AND USABILITY.
  • ECO-FRIENDLY CHOICE: PROMOTE SUSTAINABILITY BY BUYING USED!
BUY & SAVE
$29.95 $49.99
Save 40%
MySQL Cookbook
10 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)
+
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.