YouTube Icon

Code Playground.

How to Delete MySQL Users Accounts

CFG

How to Delete MySQL Users Accounts

MySQL permits you to make different client records and award fitting advantages so the clients can associate and oversee information bases. 

In the event that the client account is not, at this point required, it is a smart thought to either eliminate the client advantages or to totally erase the client account. 

This instructional exercise discloses how to erase MySQL/MariaDB client accounts. 

DROP USER Statement

In MySQL, you can eliminate at least one clients and appointed advantages with the DROP USER proclamation. The overall sentence structure of this assertion is as per the following: 

DROP USER [IF EXISTS] USER_ACCOUNT [, USER_ACCOUNT] ...

For instance to eliminate the brian@localhost client account login to the MYSQL shell and run: 

DROP USER 'brian@localhost';

On progress the order will return: 

Query OK, 0 rows affected (0.00 sec)

To eliminate different client accounts in a solitary order, run the DROP USER explanation followed by the clients you need to eliminate isolated by space: 

DROP USER 'brian@localhost' 'any@localhost';

On the off chance that you attempt to drop a client account that doesn't exist and the IF EXISTS condition isn't utilized the order will restore a mistake. 

In the event that the client you are attempting to eliminate is as of now signed in, the client meeting won't be shut and the client will have the option to run inquiries until the meeting closes. When the meeting is shut the client is taken out and it will not, at this point have the option to sign in to the MySQL worker. 

The information bases and articles made by the client are not consequently taken out. 

Removing MySQL User Accounts

This part bit by bit guidelines on the most proficient method to rundown and eliminate MySQL client accounts. 

To start with, login to the MySQL shell with the root or another authoritative client. To do so type the accompanying order: 

sudo mysql

On the off chance that you are utilizing the old, local MySQL validation module to sign in as root run the order underneath and enter the secret word when provoked: 

mysql -u root -p

The orders beneath are executed inside the MySQL shell. 

MySQL stores data about the clients, in the client table in the mysql information base. Utilize the accompanying SELECT assertion to get a rundown of all MySQL client accounts : 

SELECT User, Host FROM mysql.user;

The yield should look something like this: 

+------------------+-----------+
| user             | host      |
+------------------+-----------+
| root             | localhost |
| luke             | %         |
| jabba            | localhost |
| jabba            | 10.10.8.8 |
| chewbacca        | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)

In MySQL, a client account comprises of a client name and hostname parts. jabba@localhost and jabba@10.10.8.8 are distinctive client accounts. 

Suppose the chewbacca@localhost client account is not, at this point required and we need to eliminate it. 

To erase the client run: 

DROP USER 'chewbacca'@'localhost'
Query OK, 0 rows affected (0.00 sec)

The order will eliminate the client record and its advantages. 

Since the client is eliminated you may likewise need to eliminate the information bases related with that client. 

Conclusion

To eliminate a MySQL client account utilize the DROP USER articulation followed by the name of the client you need to eliminate. 

On the off chance that you have any inquiries or criticism, don't hesitate to leave a remark.




CFG