Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import large sql file in phpmyadmin

I want to import a sql file of approx 12 mb. But its causing problem while loading. Is there any way to upload it without splitting the sql file ?

like image 956
Jasmeet Kaur Chauhan Avatar asked Jul 03 '12 06:07

Jasmeet Kaur Chauhan


3 Answers

Try to import it from mysql console as per the taste of your OS.

mysql -u {DB-USER-NAME} -p {DB-NAME} < {db.file.sql path}

or if it's on a remote server use the -h flag to specify the host.

mysql -u {DB-USER-NAME} -h {MySQL-SERVER-HOST-NAME} -p {DB-NAME} < {db.file.sql path}
like image 179
manurajhada Avatar answered Sep 22 '22 14:09

manurajhada


3 things you have to do:

in php.ini of your php installation (note: depending if you want it for CLI, apache, or nginx, find the right php.ini to manipulate)

post_max_size=500M

upload_max_filesize=500M

memory_limit=900M

or set other values.

Restart/reload apache if you have apache installed or php-fpm for nginx if you use nginx.

Remote server?

increase max_execution_time as well, as it will take time to upload the file.

NGINX installation?

you will have to add: client_max_body_size 912M; in /etc/nginx/nginx.conf to the http{...} block

like image 33
Toskan Avatar answered Sep 19 '22 14:09

Toskan


Edit the config.inc.php file located in the phpmyadmin directory. In my case it is located at C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php.

Find the line with $cfg['UploadDir'] on it and update it to $cfg['UploadDir'] = 'upload';

Then, create a directory called ‘upload’ within the phpmyadmin directory (for me, at C:\wamp\apps\phpmyadmin3.2.0.1\upload\).

Then place the large SQL file that you are trying to import into the new upload directory. Now when you go onto the db import page within phpmyadmin console you will notice a drop down present that wasn’t there before – it contains all of the sql files in the upload directory that you have just created. You can now select this and begin the import.

If you’re not using WAMP on Windows, then I’m sure you’ll be able to adapt this to your environment without too much trouble.

Reference : http://daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/comment-page-4/

like image 24
Siraj Khan Avatar answered Sep 18 '22 14:09

Siraj Khan