Sign up to Our

NEWSLETTER


 
Knowledgebase
How to import large sql files?
Posted by Edward T. on 11 April 2016 02:21 AM

Many users prefer to import a backed up database file (*.sql) through phpmyadmin,
But phpmyadmin has some limitation to file size.
Actually the limitation depends on some factors like php's max upload size.

Here we gonna show you how to import large sql files.(Normally larger than 50 MB)

 

Access your webhost's console through ssh

If you're using Cpanel, a manual can be found here:
https://documentation.cpanel.net/display/ALD/SSH+Shell+Access

 

Uploading *.sql file and preparing basics

Please upload the *.sql file, for instance "foo.sql" through FTP or a file manager (like Cpanel's file manager).
Consider we did so, and we've uploaded the "foo.sql" file directly into "public_html" directory
So it's full path would be something like this:

/home/yourdomain/public_html/foo.sql
(Also you can find it's full path through Cpanel's File Manager)

Also make sure you've created the database you like to import the "foo.sql" file into,
and you know it's privileged user's username/password

For instance:
Database name: sample_database
privileged user's "Username/Password": sample_user/sample_pass

 

Import to database

Use ssh to access your host's terminal.
Check if foo.sql file is uploaded and you have entered it's path correctly:

# ls -l /home/yourdomain/public_html/foo.sql

You should see something like this:
"-rw-rw-r--. 1 bar nobody 67286340 Mar 18 13:38 foo.sql"
(The 67286340 is file size in bytes)

But, If you see such message:
"ls: cannot access foo.sql: No such file or directory"
You are entering wrong path or file uploaded somewhere else (or not even uploaded).

Finally, Import the file into database:
#mysql -u sample_user -p sample_database < /home/yourdomain/public_html/foo.sql

You would be asked for password, just enter the password and hit Enter.
Done!


Comments (0)