Loading Now

Remove a MYSQL user on linux via ssh

Remove a MYSQL user on linux via ssh

All server administrator know and they do well on their security practices by removing users from Mysql how are no longer access or not in use.They should ensure that they get released as users change, and turnover happens. It provides security and safeguards against unlawful access to data.

This article walks you through how to remove a Mysql user on Linux using cmd in ssh,

  • A server running CentOS or AlmaLinux.
  • Root access and log in as the root user.
  • Access to the terminal.
  • Basic command line knowledge.

remove a mysql user

How to Remove a MySQL User on Linux via Command Line

Step 1: Access the MySQL Server

Login to SSH use the cmd access the MySQL server.This command specifies the root user with the -u flag. The -p flag makes MySQL prompt for a password. Enter your current password to complete the login.

mysql -u root -p

Now the system shows MYSQL cmd prompt.You can create users in MySQL or change a user password for the root or any other database user.

mysql>

Step 2: View a List of MySQL Users

The below statement allows you to view a complete list of MySQL users, including their associated host.

SELECT User,Host FROM mysql.user;

Step 3: Remove a MySQL User

To remove a user from MySQL, use the DROP command. Before it is advised that dropping a user cannot be undone. The following command removes the user testuser

DROP USER 'testuser'@'localhost';

If a user of the name testuser does not exist, you’ll receive an error.

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

Refer to step 2 if you receive the error, and double-check the username and host. Repeat the DROP command to remove the user once you confirm the appropriate username and host.

Recalling

It is easy to remove a MySQL user in Linux from the command line. These commands allow for accomplishing this task quickly. Removing a MySQL user on Linux via command line is another security measure administrators must take to secure data systems consistently.

For web hosting services shared ,reseller ,VPS or dedicated our hyderabadwebhosting provides affordable cost and in best offer.