In this MariaDB tutorial, we will discuss, how to create a database from an SQL file in MariaDB.
- MariaDB create database from sql file Windows
- MariaDB create database from SQL file Ubuntu and Linux
MariaDB create database from sql file windows
In MariaDB, we can create the database from the SQL file, this SQL file contains the command to create the database. The SQL file is saved with extension (xyz.sql).
Let’s write the SQL command to create the database in the file, open Notepad text editor.
CREATE DATABASE sqldatabase;

Open the HeidiSQL application and Load the SQL file by clicking on the Folder icon below the menu section.

After performing the above steps, a MariaDB: Confirm dialogue will appear to select the encoding method. Then select Yes.

Then click on the play icon below the menu section to execute the command in the SQL file.

After clicking on Execute button, it will create the database in the current session.
This is how to create a database from an SQL file in MariaDB in Windows.
Read MariaDB Insert Into
MariaDB create database from SQL file Ubuntu and Linux
Ubuntu users follow this section to create a database in MariaDB from sql file using the below steps.
Now open the gedit editor on Ubuntu and write the below line in that file. Save the file with the name us.sql.

Open the MariaDB prompt in the terminal using the below command and enter the password if it asks.
mysql -u root -p
After login into the MariaDB shell prompt, Create the new database as us_database.
CREATE DATABASE us_database;
Then exit from the MariaDB shell or return to the Ubuntu terminal.

In the Ubuntu terminal, write the below command to create a database from an SQL file.
mysql -u root -p us_database < us.sql
Now again log into the MariaDB shell prompt and run the below command to show the created database that is united_states.
SHOW DATABASES;

The output shows that created database as united_states in the pink color.
This is how to create a database from SQL file Ubuntu and Linux in MariaDB.
You may like the following MariaDB tutorials:
- MariaDB create procedure
- How to Change Column in MariaDB
- MariaDB Update Statement
- How to Remove User in MariaDB
- How to Grant All Privileges in MariaDB
- MariaDB Primary Key With Examples
So in this MariaDB tutorial, we have learned about the “MariaDB create a database from sql file” and covered the following topics.
- MariaDB create database from sql file Windows
- MariaDB create database from SQL file Ubuntu and Linux
I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.
Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.