Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Databases»MariaDB»How to Delete A MySQL User Account

    How to Delete A MySQL User Account

    RahulBy RahulMay 27, 20212 Mins Read

    MySQL is an relational database management system provide authentication mechanism to prevent unauthorized access. It keeps all the user details in a database named “mysql”. You must have super user access (eg: root) to access this database.

    In this article you will learn to find accounts in a MySQL server and remote unnecessary user accounts.

    View Current Users

    Connect to the existing MySQL server using administrative privileged account.

    mysql -u root -p 
    

    Next, list all the available user account in MySQL server. Default database named “mysql” contains system related details including user account under “user” table.

    SELECT User,Host FROM mysql.user; 
    

    List MySQL Users

    List out the account with hostname to delete or all unused accounts no longer required.

    Drop/Delete MySQL User

    Use DROP USER statement is used to delete one or more accounts from MySQL. It also removes privilege rows for the account from all grant tables. You must have specified username along with hostname as per showing in above screenshot.

    For example, to remove user “dummy” with host “localhost”, execute below query:

    DROP USER 'dummy'@'localhost';
    

    drop mysql user

    The above command drop only those user from MySQL maches both username and hostname.

    Let’s use another example to delete user “myuser” with hostname “%”, execute below query.

    DROP USER 'myuser'@'%';
    

    delete mysql user

    That’s it. Repeat the same command to remove more accounts no longer required.

    Conclusion

    This tutorial describes you to how to remove user accounts from MySQL database server.

    drop MySQL user
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Create SFTP Only User in Ubuntu 20.04
    Next Article How To Install Go 1.17 on Ubuntu 20.04

    Related Posts

    Backup MySQL Databases to Amazon S3 (Shell Script)

    Updated:May 28, 20222 Mins Read

    How to Install MariaDB on Ubuntu 22.04

    Updated:May 28, 20222 Mins Read

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How To Install MySQL Server on Ubuntu 22.04

    Updated:April 6, 20224 Mins Read

    How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04

    Updated:June 28, 20225 Mins Read

    How To Install MariaDB on Debian 11

    4 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    • What is the /etc/nsswitch.conf file in Linux
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.