Import large database in MySQL

Share

We generally use phpMyAdmin for importing database / tables from mySQL dump files. But when the file is large (can be 50 MB or even 700 MB) it is not possible to import it via a web interface. We can import such large files from the command prompt.

1. Open the Command prompt.

2. Go to folder where MySQL is installed. If you are running WAMP the path can be like D:\wamp\bin\mysql\mysql5.0.51b\bin (I do not install my WAMP in the drive where my OS is, hence D: 🙂 )

3. Login to MySQL by typing
mysql -u [username] -p
You will be prompted to enter the password in the next line. Type it and press Enter.
If you are working on local generally you wont need a password and can hence type
mysql -u root

4. From the MySQL prompt to select the database type
use [database_name]

5. Now to import the file type
source [file_name_with_full_path]
Like if the file is in drive F and is named test.sql, you need to type
source F:\test.sql

That would import the file. Hope you find the post useful. Njoy 🙂

This entry was posted in MySQL and tagged . Bookmark the permalink.
 

2 Responses to Import large database in MySQL

  1. ... says:

    This is genius work! Thanks!

  2. The SOURCE command is definitely not the fastest way to import a large database. Use this command instead:

    shell> mysql -u root target_database < your_dump.sql

    An even faster way is to do a raw copy of your database files if you are able to access them.

Leave a Reply

Your email address will not be published. Required fields are marked *

*