Create a Database with MariaDB

In this article, we’re going to show you how you can create a new database with MariaDB. This is going to be the same process as creating a MySQL database. However, using MariaDB in replacement of MySQL as your storage is reported to be faster and more efficient for inserting and selecting data.

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

For most users, the easiest way to create a new MariaDB database would be through the familiar cPanel interface.

  1. Log into cPanel
  2. Under Databases click MySQL Databases

    IMH Support
  3. In the Create New Database field, fill in a name for your new database

    IMH Support

  4. Click Create Database

That’s it. We have now created a MariaDB database in cPanel.

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 we do not give them access 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, we will give you a command you can run to create MariaDB databases on the command line. If you are familiar with MySQL commands, you’ll notice this one is the same.

In order to access MariaDB/MySQL on the command line, you will need to make sure you have created a database user. (See the section above.)

  1. Log into your cPanel account via the shell
  2. Log into MariaDB via this command: mysql -u db_username -p
  3. Fill in the database user password when prompted
  4. Once logged in, you will see the mysql command prompt, at which point you may type in the command to create the database:
     CREATE DATABASE db_name;

The command above will create a database named “db_name”. You may wish substitute that generic database name with something relevant to your project.

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.

CM
Christopher Maiorana Content Marketing Writer

Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.

More Articles by Christopher

Was this article helpful? Let us know!