Database MYSQL

Remove a MySQL User on Linux via Command Line

MYSQL Articles, Errors and Fixes
MYSQL Articles, Errors and Fixes

Remove a MySQL User on Linux via Command Line

CheckList:

These directions are meant for removing a MySQL  user on Linux  via the instruction.

I’ll be performing from Liquid net Core Managed CentOS half dozen.5 server, and l’ll be logged in as root.

Login to MySQL:

First, we’ll login to the MySQL server from the instruction with the following command:

mysql -u root -p

In this case, I’ve nominative the user root with the -u flag, so used the -p flag so MySQL prompts for a word. Enter your current word to complete the login.

If you wish to vary your root (or any other) word within the info, then follow this tutorial on ever-changing a word for MySQL via the statement.

You should currently be at a MySQL prompt that appears terribly like this:

mysql>

If you haven’t nonetheless created a MySQL user, please sit down with our tutorial on making a MySQL user.

View an inventory of MySQL Users

Viewing a full list of MySQL users, as well as the host they’re related to, is finished the following choose statement:

SELECT User,Host FROM mysql.user;

Remove a MySQL User

To remove a user from MySQL, we once more use the DROP command.

It solely takes one straightforward command to delete a user in MySQL, however BEWARE; dropping a user can’t be undone! The command is as follows:

DROP USER 'testuser'@'localhost';

If a user of the name testuser does not exist, then you’ll receive this error:

ERROR 1396 (HY000): Operation DROP USER failed for 'testuser'@'localhost'

Refer to the View a List of MySQL Users section above if you receive the above error, and double check the username and host.

READ  PHP - Convert from MySQL datetime to another format with PHP

About the author

Venkatesan Prabu

Venkatesan Prabu

Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.

Add Comment

Click here to post a comment