How to Create User in MariaDB/MySQL in Linux and Windows. In this tutorial we will also explain how to list all users and grant privileges to databases. Let’s get started.
It’s always a tricky one to choose the best relational database management systems. Today we are going to discuss two popular and widely used RDBMS to retrieve or store the operation data in the database server. In this MySQL vs MariaDB article, the topics which we cover are the introduction part and the major differences between MySQL and MariaDB. Let’s get started.
MySQL is an open source and popular relational database management system (RDBMS). MySQL database includes the SQL servers and client programs to access the server side data. This type of RDBMS is most commonly used by web application developers together with PHP and Apache servers. MySQL server is officially pronounced as a “my ess que ell”. It allows you to create a relational database structure on various web application servers to store the data or automates the data processing. The main reason to use MySQL is that it is much cheaper than the Oracle database, easy to use shells for creating tables or querying the database tables. And most importantly, it is easy to use with JDBC servers.
MariaDB is one of the most widely used database servers worldwide. It was first made by the original MySQL developers, so it also acts as an open source database management system. The developers include the MariaDB server in Wikipedia, Google, WordPress.com and a few search engines. MariaDB server turns the data into a structured format and is used in a wide variety of applications such as banks, Fintech companies, Health sectors and building search engine applications. The reason behind its popularity over MySQL is that it is fast to use, scalable, robust, offers rich storage engines and includes plugins while developing the websites (for example wordpress.com). It also provides a SQL (sequential query language) interface to access the data. The latest version of MariaDB also consists of GIS and JSON (javascript object notation) features.
Creating and managing users in MariaDB is very common task for any system and database administrators. In this section, we will show you how to create a MariaDB user in both Linux and Windows.
Create a User in MariaDB on Windows
First, launch the MariaDB client from the start menu and log in as a root user.
To create a user called windows and set a password, run the following command:
MariaDB [(none)]> create user windows@localhost identified by 'password';
Next, flush the privileges to apply all the changes:
MariaDB [(none)]> FLUSH PRIVILEGES;
To get a list of all MariaDB users, run the following command:
MariaDB [(none)]> select user from mysql.user;
You will get a list of all MariaDB users in the following output:
+-------------+
| User |
+-------------+
| root |
| root |
| root |
| mariadb.sys |
| root |
| windows |
+-------------+
6 rows in set (0.982 sec)
To remove a MariaDB user account, run the following command:
MariaDB [(none)]> DROP USER 'windows'@'localhost';
In a Linux or Unix operating system, you will need to log in to the MariaDB shell to create a user. You can log in to the MariaDB shell using the following command:
mysql -u root -p
You will be asked to provide a MariaDB root password to log in to the MariaDB shell. After the successful log in, create a user called linux and set a password using the following command:
MariaDB [(none)]> create user linux@localhost identified by 'password';
Next, flush the privileges to apply all the changes:
MariaDB [(none)]> FLUSH PRIVILEGES;
To get a list of all MariaDB users, run the following command:
MariaDB [(none)]> select user from mysql.user;
You should get the following output:
+-------------+
| User |
+-------------+
| root |
| root |
| root |
| mariadb.sys |
| root |
| linux |
+-------------+
6 rows in set (0.982 sec)
To remove a MariaDB user account, run the following command:
Creating and managing MySQL users is a day to day task for any database administrator. In this section, we will show you how to create a user in MySQL on Windows and Linux.
Create a User in MySQL on Windows
First, launch the MySQL client from the start menu and log in with root password. After the successful log in, create a user called user1 using the following command:
mysql> CREATE USER 'user1'@'localhost' IDENTIFIED BY 'password';
Grant all the privileges to the userdb database using the following command:
mysql> GRANT ALL ON userdb.* TO 'user1'@'localhost';
Flush the privileges to apply all the changes:
mysql> FLUSH PRIVILEGES;
To list the MySQL users, run the following command:
First, you will need to log in to the MySQL shell. You can log in using the following command:
mysql -u root -p
Provide your MySQL root password and press the Enter key to log in to the MySQL shell. Once you are log in, create a user named testuser with the following command:
mysql> CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'securepassword';
To grant all the privileges to the testdb database, run the following command:
mysql> GRANT ALL ON testdb.* TO 'testuser'@'localhost';
Now, flush the privileges to apply the changes:
mysql> FLUSH PRIVILEGES;
To list all MySQL users, run the following command:
How to Create User in MariaDB/MySQL in Linux and Windows Conclusion
In this post, we explained how to create a user in MySQL and MariaDB on both Linux and Windows operating systems. We also explained how to list all users and grant privileges to databases. I hope you can now easily create a user in MySQL and MariaDB.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
00votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.