The_Amol The_Amol - 2 years ago 94
SQL Question

How to import database from a large SQL file of hundreds MBs to MySQL

I have one SQL file which contains database and is 450+ MB. I tried phpMyAdmin, however phpMyAdmin does not support the import of such large files.

Can anyone suggest way or command to import it through command line.

Answer Source

There are multiple ways to do this.

Here's one way:

  1. Login to mysql (e.g. mysql -u root -p)
  2. Create database testimport_db;
  3. use testimport_db;
  4. source pathname_of_your_sql_file/your_sql_filename.sql

Here's a screenshot:

enter image description here

Other ways:

Note: If you get the path of your sql fle wrong. Then use absolute path instead. Related post


Another way:

mysql -uroot -p[your_password] database_name < sql file

If you want to run this as background process in LINUX then put an & at the end like below:

mysql -uroot -p[your_password] database_name < sql file &

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download