How to Import Database in MySQL Using Command Line

Reading Time: 3 minutes

Inside this article we will see how to import database in mysql using command line in ubuntu operating system. Tutorial will be super easy to understand.

When you have a large size of database then we can not easily import from phpmyadmin manual interface. So in that case we need to use mysql commands for it. Here, we will see a simple command to import large size database in mysql using command in ubuntu.

We can import databases in mysql in several ways. But in this tutorial we will use a command which will be executed from terminal in ubuntu to import.

Learn More –

Let’s get started.

Manual PhpMyAdmin Interface For Import

As we have two options available to import data in MySQL. Options are –

  • Manual Interface of PhpMyAdmin
  • Using Command Line of MySQL

Import Data To MySQL

Inside this import page we have several settings available about import database to mysql.

But if we have large size database or say import manual tool is not working then in these cases we can use command line.

MySQL Import Database via Interactive Mode

Inside this case we are going to use terminal and few commands of mysql to use MySQL interactive mode.

Also here, we have multiple options to choose file formats for import . We will use .sql to understand.

Import data to MySQL Table


$ mysql -u {username} -p {database_name} < {file_path}


$ mysql -u root -p db_management < /var/www/html/dbt/data.sql

When you press enter you need to pass password and then data will be automatically import to your selected database.

data.sql file will be imported to db_management database. /var/www/html/dbt/data.sql is file path.

We hope this article helped you to learn about How to Import Database in MySQL Using Command Line in Ubuntu in a very detailed way.

Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Sanjay KumarHello friends, I am Sanjay Kumar a Web Developer by profession. Additionally I'm also a Blogger, Youtuber by Passion. I founded Online Web Tutor and Skillshike platforms. By using these platforms I am sharing the valuable knowledge of Programming, Tips and Tricks, Programming Standards and more what I have with you all. Read more