MySQL large file import through console

Perhaps you have erncountered that exported database files are too large for PHP to handle even if you change upload_max_filesize, timeout etc. One solution is to do the import via MySQL console.

How do you do it? Well, to begin to start up MySQL's console by typing:

  mysql -u root

in dos (CMD.exe in Windows XP), alternatively if you are using WAMP, start MySQL console via the WAMP menu (Figure 1).

Figure 1. MySQL console via WAMP

Once you have logged into mysql, it should look like in Figure 2. 

Figure 2. Logged into MySQL console

Select the database you want to work on with the command:

use DBNAME
 

Then it is just a matter of writing the correct path to the file you want to import, ie. the .sql file you want to run. Do this with the command:

source C:\FILENAME.sql

That's all for this time, a quick solution on how to import a large file into MySQL through the console.