MySQL Tutorial
MySQL Installation and Configuration
MySQL Database Operations
Database Design
MySQL Data Types
MySQL Storage Engines
MySQL Basic Operations of Tables
MySQL Constraints
MySQL Operators
MySQL Function
MySQL Manipulate Table Data
MySQL View
MySQL Indexes
MySQL Stored Procedure
MySQL Trigger
MySQL Transactions
MySQL Character Set
MySQL User Management
MySQL Database Backup and Recovery
MySQL Log
MySQL Performance Optimization
To delete a user account in MySQL, you use the DROP USER
statement. Here's how to do it:
Step 1: Login to MySQL
First, you need to login to MySQL using the mysql
command in your terminal or command prompt:
mysql -u root -p
You will be prompted to enter the password for the root
user.
Step 2: Drop User
Once you are logged in, you can delete a user with the DROP USER
command:
DROP USER 'username'@'localhost';
Replace 'username'
with the name of the user you want to delete.
Note:
'localhost'
part after the @
symbol specifies that you want to drop the account for the user who connects from the localhost. If the user connects from another host, you should specify that host name instead of localhost
. If the user can connect from any host, use the '%'
wildcard character: 'username'@'%'
.Step 3: Exit MySQL
You can exit the MySQL shell by typing:
EXIT;
Important:
DROP USER
statement as it permanently removes a user from the MySQL server.CREATE USER
privilege or the DELETE
privilege for the mysql
system database to use the DROP USER
statement.DROP USER
statement also removes the user's privileges and deletes the account's rows from the user
table in the mysql
system database.Deleting a user in MySQL:
DROP USER 'username'@'hostname';
How to remove a user in MySQL:
DROP USER 'username'@'hostname';
MySQL DELETE USER command:
DROP USER 'username'@'hostname';
Revoke privileges and drop user in MySQL:
REVOKE ALL PRIVILEGES ON *.* FROM 'username'@'hostname'; DROP USER 'username'@'hostname'; FLUSH PRIVILEGES;
Removing MySQL user accounts:
REVOKE ALL PRIVILEGES ON *.* FROM 'username'@'hostname'; DROP USER 'username'@'hostname'; FLUSH PRIVILEGES;
Delete user and revoke privileges in MySQL:
REVOKE ALL PRIVILEGES ON *.* FROM 'username'@'hostname'; DROP USER 'username'@'hostname'; FLUSH PRIVILEGES;
MySQL drop user and associated privileges:
REVOKE ALL PRIVILEGES ON *.* FROM 'username'@'hostname'; DROP USER 'username'@'hostname'; FLUSH PRIVILEGES;
MySQL user account cleanup:
REVOKE ALL PRIVILEGES ON *.* FROM 'username'@'hostname'; DROP USER 'username'@'hostname'; FLUSH PRIVILEGES;