In this article, you will learn how to create a new database with MariaDB. This is going to be the same process as creating a MySQL database, so those of you familiar with MySQL maintenance should have no problem switching over to MariaDB.
If you have not done so already, you should read our tutorial on how to install MariaDB as a replacement for MySQL.
- How to Create a New MariaDB Database Using cPanel
- How to Create a MariaDB Database on the Command Line
How to Create a New MariaDB Database Using cPanel
For most users, the easiest way to create a new MariaDB database would be through the familiar cPanel interface.
- Log into cPanel
- Under Databases click MySQL Databases
- In the Create New Database field, fill in a name for your new database
- Click Create Database
That’s it. We have now created a MariaDB database in cPanel. You should see a success message indicating that the database was created successfully. If you notice an error, or do not see the database you created, you may have a limit on how many databases you can create or there may be a system error. In the latter case you can contact live support for assistance.
How to Assign a Database User
To use the database you have just created, you must create and assign a user with privileges to manage it. To do so, follow the same steps as above, but scroll down past the database creation until you see the heading: MySQL Users. Under Add New User, fill in a username, a password, and then click Create User.
Assign Privileges to the New User
The new user will not have the power to do anything if you do not give them the necessary privileges to make changes. In order to do this, scroll down further on the same page as above. Under the section headed Add User To Database. Select the database and user under their respective field. On the next screen, select the box for All Privileges and click Make Changes.
How to Create a MariaDB Database on the Command Line
Through the steps below, you can learn to create MariaDB databases on the command line. If you are familiar with MySQL commands, you’ll notice this one is the same.
To start, log into your server using SSH. Then, you can log into the MariaDB command prompt:
mysql -u <username> -p
<username> with your actual username and provide your password. This can be the database user previously created, your cPanel user, or the root user (if you have a VPS). For example:
mysql -u root -p
To create a database, use the “create database” command as follows:
CREATE DATABASE <database_name>;
Of course, replace
<database_name> with the name of the database you are creating.
The user you have logged in as must have CREATE privileges assigned in order to use the CREATE DATABASE function.
Now that you have created a database in two different ways, you can choose whichever method works best for you. If you have any trouble, drop us a question, and we will be happy to help.
Get better performance and security with our VPS Hosting.