EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials MariaDB Tutorial MariaDB import SQL
Secondary Sidebar
MariaDB Tutorial
  • MariaDB
    • MariaDB Versions
    • MariaDB? list users
    • MariaDB Commands
    • MariaDB odbc
    • MariaDB Workbench
    • MariaDB for windows
    • MariaDB Server
    • MariaDB? Data Types
    • MariaDB? boolean
    • MariaDB phpMyAdmin
    • MariaDB Mysqldump
    • MariaDB Java Connector
    • MariaDB insert
    • MariaDB UPDATE
    • MariaDB? rename column
    • MariaDB AUTO_INCREMENT
    • MariaDB Timezone
    • MariaDB GROUP_CONCAT
    • MariaDB wait_timeout
    • MariaDB MaxScale
    • MariaDB? with
    • MariaDB GUI
    • MariaDB? create?table
    • MariaDB? SHOW TABLES
    • MariaDB alter table
    • MariaDB List Tables
    • MariaDB JSON Functions
    • MariaDB Foreign Key
    • MariaDB? trigger
    • MariaDB Grant All Privileges
    • MariaDB Select Database
    • MariaDB? create database
    • MariaDB Delete Database
    • MariaDB Join
    • MariaDB JSON
    • MariaDB? show databases
    • MariaDB List Databases
    • MariaDB Functions
    • MariaDB? TIMESTAMP
    • MariaDB create user
    • MariaDB add user
    • MariaDB Max Connections
    • MariaDB show users
    • MariaDB Delete User
    • MariaDB? change user password
    • MariaDB? change root password
    • MariaDB reset root password
    • MariaDB IF
    • MariaDB bind-address
    • MariaDB Transaction
    • MariaDB Cluster
    • MariaDB Logs
    • MariaDB Encryption
    • MariaDB? backup
    • MariaDB Replication
    • MariaDB max_allowed_packet
    • MariaDB? performance tuning
    • MariaDB export database
    • MariaDB? import SQL

MariaDB import SQL

MariaDB import SQL

Introduction to MariaDB import SQL

MariaDB provides the important SQL functionality to the user, in which we can import SQL files into the MariaDB server. In MariaDB we can use mysql command to import the sql file. Import sql is very good when a user handles the websites or blog. Sometimes databases are corrupted or we need to migrate to a different server or development environment. At that time we can use the import sql concept to achieve our desired goal. To perform import sql commands we must have a root access of the MariaDB server and it is suitable to run different commands. The import sql uses the mysql command to import the sql file into our desired location as per requirement.

Syntax

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

mysql –u specified user name – password of that user =  database name < sql file name

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,268 ratings)

Explanation

In above syntax we use mysql command to import the sql file in the MariaDB server; here specified user means actual user name with password of that user and database name is used to specify database data to import the sql file. Last part of the above syntax shows the actual sql file name that we need to import into the MariaDB server.

How to import SQL in MariaDB?

Now let’s see how we can import sql into the MariaDB server as follows.

Creating backups of our website or any application is basically an important thing, because we don’t refer only to website files or applications but we also refer databases. Suppose an incident may occur such as system crush or data loss, so we must require the database when we update the technology, or data may be lost or we use a new environment. At that time we need a backup of all files as well as database files that sql file to migrate one environment to another development environment.

First we must have root access to import sql into the MariaDB server and we also require the database name, specified user name and password of that user to access the database.

Examples

Now let’s see different examples of important sql into MariaDB as follows.

First we login successfully into the MariaDB server by using private credentials such as user name and password.

After login we must need to create a new database by using the following syntax as follows.

Syntax

create database specified database name;

Explanation

In the above syntax we use the create database command to create a new database, here specified database name means actual database name that we need to create.

Example

create database sample;

Explanation

In the above example we use the create database statement to create a new database; here sample is a specified database name that we need to create. The end output of the above query we illustrate by using the following snapshot.

MariaDB import SQL output 1

We can see the created database by using the following statement as follows.

show databases;

Explanation

In the above statement we use the show database statement to see all databases. The end output of the above query we illustrate by using the following snapshot.

MariaDB import SQL output 2

Now we have a new database name as a sample and we also have all privileges to import sql files into the MariaDB server.

mysql –u root –p sample < demo1.sql

Explanation

In above example we use mysql command to import sql file into the MariaDB, here username is root as shown in above statement and p for password for that specified user, sample is database name that we already created and demo1.sql is a sql file that we need to import into the MariaDB server.

Using the above command, we can easily restore the newly created database into the MariaDB server. The above runs from the directory where sql file is stored otherwise we can provide an actual path. After the execution of the above statement we need to enter the user password. After inserting the password it imports the sql file into the sample database. The end output of the above query we illustrate by using the following snapshot.

MariaDB import SQL output 3

If our sql file is located in a different location then we need to specify the path of the sql file.

We can also import sql files directly by using a dashboard and it is a very easy way to import the sql file.

Now see how we can provide the path to import the sql file into the MariaDB server as follows.

mysql  - -user = ’root’ - -password= ‘*******’ sample < ‘backup/demo1.sql’

Explanation

In the above example we use the mysql command to import the sql. In this example root is the username and password is used to specify the user, here password shows in star but actually it is in plaintext format. The sample is database name and after that we specified the path of the sql file that we need to import into the MariaDB server.

If sql file already exists into the MariaDB server then we cannot import sql again and again because data redundancy means it avoids the data duplication as well as it also minimizes the wastage of memory space.

It is always great to know how much simplest statements we use in MariaDB to import sql files. MariaDB statement is the minimum statement that is used in import that means a single statement allows us to do accurate action. There are many other aspects of import sql statement into MariaDB that we have not addressed here. We also have another way to import sql that is Perl modules that could be used to convert data files and this module is used to import the script. There are many ways to import sql into server.

Conclusion

We hope from this article you have understood about the MariaDB import sql. From this article we have learned the basic syntax of import sql and we also see different examples of import sql. From this article we learned how and when we use MariaDB import sql.

Recommended Articles

This is a guide to MariaDB import SQL. Here we discuss the basic syntax of import sql and we also see different examples of import sql. You may also have a look at the following articles to learn more –

  1. MariaDB Timezone
  2. MariaDB MaxScale
  3. MariaDB Foreign Key
  4. MySQL Query Cache
Popular Course in this category
SQL Training Program (7 Courses, 8+ Projects)
  7 Online Courses |  8 Hands-on Projects |  73+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more