{"id":277,"date":"2024-02-03T05:46:21","date_gmt":"2024-02-03T05:46:21","guid":{"rendered":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/?p=277"},"modified":"2024-02-03T05:47:00","modified_gmt":"2024-02-03T05:47:00","slug":"remove-a-mysql-user-linux","status":"publish","type":"post","link":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/remove-a-mysql-user-linux\/","title":{"rendered":"Remove a MYSQL user on linux via ssh"},"content":{"rendered":"<p>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.<\/p>\n<p>This article walks you through how to remove a Mysql user on Linux using cmd in ssh,<\/p>\n<div data-lw-block-type=\"heading\" data-lw-block-attributes=\"\">\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/remove-a-mysql-user-linux\/#Prerequisites\" >Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/remove-a-mysql-user-linux\/#How_to_Remove_a_MySQL_User_on_Linux_via_Command_Line\" >How to Remove a MySQL User on Linux via Command Line<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/remove-a-mysql-user-linux\/#Step_1_Access_the_MySQL_Server\" >Step 1: Access the MySQL Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/remove-a-mysql-user-linux\/#Step_2_View_a_List_of_MySQL_Users\" >Step 2: View a List of MySQL Users<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/remove-a-mysql-user-linux\/#Step_3_Remove_a_MySQL_User\" >Step 3: Remove a MySQL User<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/remove-a-mysql-user-linux\/#Recalling\" >Recalling<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 id=\"h-prerequisites\" class=\"Heading__SHeading-sc-o0nhd6-0\"><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<\/div>\n<div data-lw-block-type=\"list\" data-lw-block-attributes=\"\">\n<ul class=\"list-disc list-outside\">\n<li>A server running CentOS or <a href=\"https:\/\/almalinux.org\/\" target=\"_blank\" rel=\"noopener\">AlmaLinux<\/a>.<\/li>\n<li>Root access and log in as the root user.<\/li>\n<li>Access to the terminal.<\/li>\n<li>Basic command line knowledge.<\/li>\n<\/ul>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-284 size-full\" src=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-content\/uploads\/2024\/02\/mysql-user-remove.png\" alt=\"remove a mysql user\" width=\"685\" height=\"425\" srcset=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-content\/uploads\/2024\/02\/mysql-user-remove.png 685w, https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-content\/uploads\/2024\/02\/mysql-user-remove-300x186.png 300w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/p>\n<div data-lw-block-type=\"list\" data-lw-block-attributes=\"\">\n<div data-lw-block-type=\"heading\" data-lw-block-attributes=\"\">\n<h2 class=\"Heading__SHeading-sc-o0nhd6-0\"><span class=\"ez-toc-section\" id=\"How_to_Remove_a_MySQL_User_on_Linux_via_Command_Line\"><\/span>How to Remove a MySQL User on Linux via Command Line<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<\/div>\n<div data-lw-block-type=\"heading\" data-lw-block-attributes=\"{&quot;level&quot;:3}\">\n<h3 class=\"Heading__SHeading-sc-o0nhd6-0\"><span class=\"ez-toc-section\" id=\"Step_1_Access_the_MySQL_Server\"><\/span>Step 1: Access the MySQL Server<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>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.<\/p>\n<\/div>\n<\/div>\n<pre>mysql -u root -p<\/pre>\n<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.<\/p>\n<pre>mysql&gt;<\/pre>\n<div data-lw-block-type=\"heading\" data-lw-block-attributes=\"{&quot;level&quot;:3}\">\n<h3 class=\"Heading__SHeading-sc-o0nhd6-0\"><span class=\"ez-toc-section\" id=\"Step_2_View_a_List_of_MySQL_Users\"><\/span>Step 2: View a List of MySQL Users<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<\/div>\n<div data-lw-block-type=\"paragraph\" data-lw-block-attributes=\"\">\n<p class=\"Paragraph__SParagraph-sc-1p2ggqg-0\">The below statement allows you to view a complete list of MySQL users, including their associated host.<\/p>\n<pre>SELECT User,Host FROM mysql.user;<\/pre>\n<div data-lw-block-type=\"heading\" data-lw-block-attributes=\"{&quot;level&quot;:3}\">\n<h3 class=\"Heading__SHeading-sc-o0nhd6-0\"><span class=\"ez-toc-section\" id=\"Step_3_Remove_a_MySQL_User\"><\/span>Step 3: Remove a MySQL User<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<\/div>\n<div data-lw-block-type=\"paragraph\" data-lw-block-attributes=\"\">\n<p class=\"Paragraph__SParagraph-sc-1p2ggqg-0\">To remove a user from MySQL, use the <em>DROP <\/em>command. Before it is advised that dropping a user cannot be undone. The following command removes the user <em>testuser<\/em><\/p>\n<pre>DROP USER 'testuser'@'localhost';<\/pre>\n<p>If a user of the name <em>testuser <\/em>does not exist, you&#8217;ll receive an error.<\/p>\n<pre>ERROR 1396 (HY000): Operation DROP USER failed for 'testuser'@'localhost'<\/pre>\n<div data-lw-block-type=\"paragraph\" data-lw-block-attributes=\"\">\n<p class=\"Paragraph__SParagraph-sc-1p2ggqg-0\">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.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Recalling\"><\/span><strong>Recalling<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>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.<\/p>\n<p>For web hosting services shared ,reseller ,VPS or dedicated our <a href=\"https:\/\/www.hyderabadwebhosting.co.in\">hyderabadwebhosting<\/a> provides affordable cost and in best offer.<\/p>\n<\/div>\n<div data-lw-block-type=\"spacer\" data-lw-block-attributes=\"{&quot;height&quot;:21}\">\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":284,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42,66],"tags":[67,68,69],"class_list":["post-277","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-ssh","tag-mysql","tag-remove","tag-user"],"_links":{"self":[{"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/posts\/277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":7,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":285,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/posts\/277\/revisions\/285"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/media\/284"}],"wp:attachment":[{"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}