If you are a tech professional, you must know about relational databases. Both MySQL and MariaDB belong to this category. You have to execute several commands to perform some functions in both cases.
We are here to explain the method to remove an anonymous user from MySQL and MariaDB! Let’s begin! For a deeper understanding of your MySQL setup, you may also want to check out our guide on how to check your MySQL version to ensure you're working with the latest features and security updates.
How to remove anonymous users from MySQL or MariaDB?
When you install MySQL, there is a default root user and an anonymous user, both with a blank password. Blank passwords are highly insecure. You must set a password for the root user and remove the anonymous user for security purposes.
Additionally, this anonymous user account permits anyone to connect with MySQL Server without the user account. The primary purpose of this account is for testing, and it shall be removed at a later stage. For a comprehensive approach to securing your databases, be sure to check out our guide on how to secure MariaDB and MySQL databases, which covers essential steps to enhance your database security.
To remove the anonymous user from MySQL or MariaDB, type in the following command:
Open the terminal on your device and follow these steps.
Step 1: As the root user, open MySQL.
$ mysql -u root -p
OR
$ sudo mysql
Step 2: Now, use the DROP USER command as given below:
mysql> DROP USER 'abc’@'localhost';
After you execute this command, MySQL raises a QUERY OK. You will notice that the user is not available in your database anymore.
Additionally, here are some steps if you wish to create a user in MySQL or MariaDB!
How to create a user in MySQL or MariaDB?
The create user statement helps develop new accounts and enables authentication, password management properties, etc., for the new accounts. For a detailed guide on creating user accounts in MySQL, check out our article on how to create a user in MySQL.
To create a MySQL user account, execute the following command:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'user_password';
Additionally, if you wish to establish a connection as a user with any host, you can use the ‘%’ wildcard. Here is the usage:
CREATE USER 'newuser'@'%' IDENTIFIED BY 'user_password';
Lastly, you can also grant privileges to a user account by following the below-stated commands in various instances.
To grant the privileges on a particular database:
GRANT ALL PRIVILEGES ON database_name.* TO 'database_user'@'localhost';
To grant multiple privileges on a specific database:
GRANT SELECT, INSERT, DELETE ON database_name.* TO database_user@'localhost’;
To grant privileges to a user account in all the databases:
GRANT ALL PRIVILEGES ON *.* TO 'database_user'@'localhost';
Conclusion
The world of MySQL, an open-source relational DBMS, lets you execute plenty of commands for different purposes. It helps you to create various user accounts and grant privileges according to the requirement. This article assists you to understand some of the basic commands that further helps you to remove an anonymous user as well as create a user. Also If you're looking to secure your online activities with utmost privacy and anonymity, consider buying anonymous VPS hosting from the renowned brand 1gbits. With their top-notch services, you can ensure your data remains confidential and your online presence remains untraceable, granting you peace of mind in today's interconnected world.
We hope that the information will halt all your ambiguities related to the topic. Keep learning, keep practising!
To further enhance your understanding of database management systems, you might find it helpful to explore the differences between MySQL and MariaDB in our article on MySQL vs. MariaDB. This comparison will provide valuable insights into their functionalities and help you make an informed decision for your projects.
People also read: