Search

How to Import SQL Files into a MySQL database using Command Line

post-title

In this article, I will share with you how to import multiple SQL files in the database at the same time using a command line. many developers don't know how the import more than one file at the same time using the command line in ubuntu. so, here I will share one trick for this problem.

If you have multiple SQL files in one folder and you want to import that all at the same time so, no need to waste your time. please follow the simple steps.

Merge all file into one file

First, we need to merge that all SQL files into one single file using the below ubuntu command.

cat *.sql  > all_files.sql

then import that file in your selected database using the following command.

Login mySql

sudo mysql -u root -p

then hit the Enter and put your MySQL password.

Select Database

use your_database_name

Import selected SQL file

source path_your_sql_file

i hope you like this article.