How to Delete a User From MariaDB on Ubuntu 22.04


In the recent post, we demonstrated the approach for changing the user’s password in MariaDB on Ubuntu 22.04. Today’s post is about discussing the method for deleting a specific user from MariaDB.

Deleting a user in MariaDB means removing their account and associated privileges from the database. When a user is deleted, this will terminate their access to the database and all previously granted actions, ensuring the security of the database.

How to Delete a User From MariaDB on Ubuntu 22.04?

Removing or deleting a user in MariaDB on Ubuntu may be necessary for various reasons. This includes revoking access when a user no longer requires it to maintain security, preventing malicious activity by deleting compromised accounts, and removing access for employees who have left the company.

Additionally, cleaning up old or unused accounts can help improve overall performance, and deleting mistakenly created accounts can be helpful in creating new ones with the correct permissions.

This section will specifically elaborate on the procedure for deleting a specific user from MariaDB on Ubuntu 22.04.

Step 1: Launch Ubuntu’s Terminal

Utilize the “Application menu” or the shortcut method “CTRL+ALT+T” to open up the terminal:

Step 2: Access to MariaDB Shell

As the next step, run the mentioned command for accessing the MariaDB’s shell:

sudo mysql -u root -p

Step 3: Select Database

Next, select a particular database:

USE mysql;

Step 4: Delete the User

Make use of the command below for deleting a user from the selected database:

DROP USER 'nextclouduser'@'localhost';

Step 5: Delete Multiple Users (optional)

The following commands can be executed for deleting or removing multiple users from a selected database:

DROP USER 'sharqa'@'localhost';

DROP USER 'author'@'localhost';

Step 6: Verify Deletion

Once you have deleted the specified user, you can verify its deletion by utilizing the command below:

SELECT User FROM mysql.user;


That was all about deleting a specific user from MariaDB on Ubuntu 22.04.

Conclusion

To delete a specific user from MariaDB on Ubuntu 22.04, open up Ubuntu’s terminal. After that, access the MariaDB shell. Then, select a particular database using the “USE mysql;” command. Next, utilize the “DROP USER ‘nextclouduser’@’localhost’;” command for deleting a specific user.  That’s how you can delete a specific user from MariaDB on Ubuntu 22.04.

Print Friendly, PDF & Email
Categories