How to import large sql file in XAMPP ?

When you have large SQL file and you want to import existing data from other installation or from host.  First you need to export the data. But sometime we may face such a situation, import large sql file in XAMPP.

In this article you will learn how to import large sql file with the command prompt in XAMPP for Windows.

We will use Command-Line Tools (Shell) to import large database SQL file.

Import mysql db using command line is very simple statements, effective and fast compare to importing huge database from phpmyadmin. There are one more advantage using this method the default mysql db upload file size is doesn’t a matter using Command-Line Tools (Shell).

#1. Open the XAMPP Control Panel

Make sure Apache and MySQL are running and click the Shell button in the XAMPP Control Panel.

xampp control panel

#2. To import database, use the following command

mysql -u username -p database_name < "/path/file.sql"

Where:

  • username – your MySQL username. e.g. root
  • database_name – database name you are importing to
  • /path/file.sql – full path to your .sql file

when you haven’t created a MySQL username. In that case, you need to type “root” for the username.

Note: On the below screen command, you will define own define own database name. The database name will be the one that you created in the phpMyAdmin and would like to import to SQL file. In our case, we have database name “the_code_developer”.

command prompt

Enter password: (leave it blank, it’s not set by default) and click enter to continue process.

command prompt enter password

#3. If you want to see import process to screen then use the following command

mysql -u username -p -v database_name < "/path/file.sql"

command prompt with output

Once your database SQL file successfully import then you will get following response like in the below image.

successfully response

19 Comments
  1. Pastelka says

    You save my day!

    1. Full Stack developer says

      I’m glad it helped you. Happy coding.

  2. jay says

    Woah! This tutorial was exactly what my giantic sql-db needed. Thank you so much, you’re a life-saver!

    1. Full Stack developer says

      Thanks, I’m glad it helped you!

  3. mani gopal says

    how to do the same process for live hosting via cPanel ?

    can you share the article based on it.

  4. Jason says

    Totally saved my day, too! Thanks 🙂

  5. paras shah says

    Its working cool
    Thank you so much sir

  6. Shubham Mathur says

    This is one of the best article in google list

  7. luis says

    thank you… works like a charm!

    1. Vikas Kumar says

      You’re welcome. Happing Coding.

  8. Sally says

    You’ve saved me .. thank you

    1. Vikas Kumar says

      You’re welcome. Happing Coding.

  9. Vinod says

    Thanks..ur article very helpful..

    1. Vikas Kumar says

      You’re welcome. Happing Coding.

  10. Enes says

    I takes a lof of time to import an 8 gb file. Do you know another way to import it fast?

  11. Krishna Vala says

    Wow, it’s very useful and also saved my time. Thank you sir.

  12. nze says

    completely useful i love this saved my ass what about on cpanel any help

  13. alex says

    thank you bro!!

  14. Sudesh Roul says

    Thank you so much sir

Leave A Reply

Your email address will not be published.