{"id":1618,"date":"2012-01-09T23:29:49","date_gmt":"2012-01-09T15:29:49","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=1618"},"modified":"2023-04-28T09:49:59","modified_gmt":"2023-04-28T09:49:59","slug":"how-to-delete-anonymous-users-from-mysql-on-centos-6-2","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-delete-anonymous-users-from-mysql-on-centos-6-2\/","title":{"rendered":"How to Delete Anonymous Users From MySQL on CentOS 6.2"},"content":{"rendered":"<p>MySQL is a popular open-source database management system used by many web applications. By default, MySQL creates an anonymous user account with no password, which can be a security risk.<\/p>\n<p>In this guide, we will show you how to delete anonymous users from MySQL on CentOS 6.2.<\/p>\n<h2>Step 1: Access MySQL as the Root User<\/h2>\n<p>The first step is to access the MySQL server as the root user. Run the following command in your terminal:<\/p>\n<pre>mysql -u root -p<\/pre>\n<p>This command will prompt you to enter the MySQL root user password. Enter the password and press Enter to log in.<\/p>\n<h2>Step 2: View Existing Users<\/h2>\n<p>Next, you need to view the existing MySQL users. Run the following command:<\/p>\n<pre>SELECT user,host FROM mysql.user;<\/pre>\n<p>This command will show you a list of all the users in the MySQL user table.<\/p>\n<h2>Step 3: Delete Anonymous Users<\/h2>\n<p>Now that you have a list of users, you can delete the anonymous user accounts. Run the following command:<\/p>\n<pre>DELETE FROM mysql.user WHERE user='';<\/pre>\n<p>This command will delete all the anonymous user accounts from the MySQL user table.<\/p>\n<h2>Step 4: Apply the Changes<\/h2>\n<p>Finally, you need to apply the changes by running the following command:<\/p>\n<pre>FLUSH PRIVILEGES;<\/pre>\n<p>This command will reload the MySQL privileges table and apply the changes you made.<\/p>\n<h2>Step 5: Exit MySQL<\/h2>\n<p>Now that you have deleted the anonymous users, you can exit MySQL by running the following command:<\/p>\n<pre>exit<\/pre>\n<pre class=\"code\">\r\n[root@centos6 ~]# mysql -u root -p\r\nEnter password:\r\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\r\nYour MySQL connection id is 150\r\nServer version: 5.1.52 Source distribution\r\n\r\nCopyright (c) 2000, 2010, Oracle and\/or its affiliates. All rights reserved.\r\nThis software comes with ABSOLUTELY NO WARRANTY. This is free software,\r\nand you are welcome to modify and redistribute it under the GPL v2 license\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nmysql> select user,host,password from mysql.user;\r\n+---------------+-----------+-------------------------------------------+\r\n| user          | host      | password                                  |\r\n+---------------+-----------+-------------------------------------------+\r\n| root          | localhost |                                           |\r\n| root          | centos6.2 |                                           |\r\n| root          | 127.0.0.1 |                                           |\r\n|               | localhost |                                           |\r\n|               | centos6.2 |                                           |\r\n+---------------+-----------+-------------------------------------------+\r\n7 rows in set (0.00 sec)\r\n\r\nmysql> delete from mysql.user where user='';\r\nQuery OK, 2 rows affected (0.00 sec)\r\n\r\nmysql> select user,host,password from mysql.user;\r\n+---------------+-----------+-------------------------------------------+\r\n| user          | host      | password                                  |\r\n+---------------+-----------+-------------------------------------------+\r\n| root          | localhost |                                           |\r\n| root          | centos6.2 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |\r\n| root          | 127.0.0.1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |\r\n+---------------+-----------+-------------------------------------------+\r\n5 rows in set (0.00 sec)\r\n\r\nmysql> exit\r\nBye\r\n<\/pre>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">mysql -u root -p<\/span> &#8211; Access MySQL as the root user<\/li>\n<li><span class=\"fw-bold\">SELECT user,host FROM mysql.user;<\/span> &#8211; View existing MySQL users<\/li>\n<li><span class=\"fw-bold\">DELETE FROM mysql.user WHERE user=&#8221;;<\/span> &#8211; Delete anonymous users<\/li>\n<li><span class=\"fw-bold\">FLUSH PRIVILEGES;<\/span> &#8211; Apply the changes<\/li>\n<li><span class=\"fw-bold\">exit<\/span> &#8211; Exit MySQL<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this guide, we have shown you how to delete anonymous users from MySQL on CentOS 6.2. By following these steps, you can improve the security of your MySQL server by removing the default anonymous user accounts. We recommend that you regularly review the user accounts on your MySQL server and delete any that are no longer necessary.<\/p>\n<p>If you have any comments or suggestions for improvements, please feel free to share them below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL is a popular open-source database management system used by many web applications. By default, MySQL creates an anonymous user account with no password, which can be a security risk&#8230;.<\/p>\n","protected":false},"author":6,"featured_media":343,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1008],"tags":[1536,1585,1744],"class_list":["post-1618","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-linux","tag-mysql","tag-security"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=1618"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1618\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/343"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=1618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=1618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=1618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}