How to Import Database in MySQL Using Command Line

Share this Article
Reading Time: 3 minutes
2,334 Views

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

Syntax:

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

Example:

$ 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.

Buy Me a Coffee

Online Web Tutor invites you to try Skillshare free for 1 month! Learn CakePHP 4, Laravel APIs Development, CodeIgniter 4, Node Js, etc into a depth level. Master the Coding Skills to Become an Expert in Web Development. So, Search your favourite course and enroll now. Click here to join.

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.

Was this post helpful?

Learn Web Development Courses Risk Free @ $5 only.
Web Development Courses @ $5