Can't import database through phpmyadmin file size too large
Asked Answered
S

14

86

I have been trying to import Database through phpMyAdmin. My database file is a.sql and it's size is 1.2 GB I am trying to import this on local and phpMyAdmin is saying:

You probably tried to upload too large file. Please refer to documentation for ways to workaround this limit.

Please help I really need this to work.

Sunshade answered 6/3, 2012 at 22:45 Comment(2)
did you refer to the documentation? do you have shell access to your server?Lali
Best AnsCimabue
R
79

Its due to PHP that has a file size restriction for uploads.

If you have terminal/shell access then the above answers @Kyotoweb will work.

one way to get it done is that you create an .htaccess/ini file file to change PHP settings to get the sql file uploaded through PHPmyAdmin.

php_value upload_max_filesize 120M //file size
php_value post_max_size 120M
php_value max_execution_time 200
php_value max_input_time 200

Note you should remove this file after upload.

Recrement answered 6/3, 2012 at 23:0 Comment(4)
Thanks alot. It worked but I more option was needed, we have to add a variable ($cfg ['ExecTimeLimit'] = 0;)which we have to declare in c:\wamp\apps\phpmyadmin\config.inc.php. I am providing the links here (john-dugan.com/?p=638)Sunshade
Or you can edit /etc/php.ini in RedHat 6.6 using the same directives above , always restart apache such as: sudo service httpd restart in RedHat.Moneywort
where this ini file should be created. Is in PHPmyAdmin folder?Schoolmate
@AbelJojo, This answer is bad, look here instead: https://mcmap.net/q/190006/-can-not-increase-file-upload-size-wampFrolicsome
R
100

For Upload large size data in using phpmyadmin Do following steps.

  1. Open php.ini file from C:\wamp\bin\apache\Apache2.4.4\bin Update following lines
    max_execution_time = 259200
    max_input_time = 259200
    memory_limit = 1000M
    upload_max_filesize = 750M
    post_max_size = 750M
    than after restart wamp server or restart all services Now Upload data using import function in phymyadmin. Apply second step if till not upload data.
  2. open config.default.php file in c:\wamp\apps\phpmyadmin4.0.4\libraries (Open this file accoring to phpmyadmin version)
    Find $cfg['ExecTimeLimit'] = 300;Replace to $cfg['ExecTimeLimit'] = 0;
    Now you can upload data.

You can also upload large size database using MySQL Console as below.

  1. Click on WampServer Icon -> MySQL -> MySQL Consol
  2. Enter your database password like root in popup
  3. Select database name for insert data by writing command USE DATABASENAME
  4. Then load source sql file as SOURCE C:\FOLDER\database.sql
  5. Press enter for insert data.

Note: You can't load a compressed database file e.g. database.sql.zip or database.sql.gz, you have to extract it first. Otherwise the console will just crash.

Raddled answered 12/3, 2014 at 6:0 Comment(3)
+1 for mysql console. 600mb database imported in 30 seconds. Using xampp, method: cmd > cd {xampp_dir}/mysql/bin > mysql -h localhost -u root {db_name} > enter password then step 4 from above solution.Hanging
If using xampp, then the php.ini file will be found at C:\xampp\php.Aspinwall
This worked for me, thanks a lotAmick
R
79

Its due to PHP that has a file size restriction for uploads.

If you have terminal/shell access then the above answers @Kyotoweb will work.

one way to get it done is that you create an .htaccess/ini file file to change PHP settings to get the sql file uploaded through PHPmyAdmin.

php_value upload_max_filesize 120M //file size
php_value post_max_size 120M
php_value max_execution_time 200
php_value max_input_time 200

Note you should remove this file after upload.

Recrement answered 6/3, 2012 at 23:0 Comment(4)
Thanks alot. It worked but I more option was needed, we have to add a variable ($cfg ['ExecTimeLimit'] = 0;)which we have to declare in c:\wamp\apps\phpmyadmin\config.inc.php. I am providing the links here (john-dugan.com/?p=638)Sunshade
Or you can edit /etc/php.ini in RedHat 6.6 using the same directives above , always restart apache such as: sudo service httpd restart in RedHat.Moneywort
where this ini file should be created. Is in PHPmyAdmin folder?Schoolmate
@AbelJojo, This answer is bad, look here instead: https://mcmap.net/q/190006/-can-not-increase-file-upload-size-wampFrolicsome
B
38

Here is what I've done:

  1. Gone to my XAMPP installed directoy C:\xampp\php
  2. Open the "Configuration Settings" file named php.ini using your text editor, preferably you can also you Notepad for Windows machine.
  3. Somewhere nearby on line no 886, please update it to upload_max_filesize = 128M
  4. Similarly on line no 735 post_max_size = 128M
  5. On line no 442 max_execution_time = 300
  6. On line no 452 max_input_time = 60
  7. Restart your Apache from either XAMPP Control Panel or using CMD in Windows https://mcmap.net/q/190007/-basic-apache-commands-for-a-local-windows-machine

Done!

Blockish answered 6/6, 2013 at 11:0 Comment(3)
Had the same problem as the OP. This solution worked for me.Attainture
Thanks, saw a whole bunch of other more complicated answers and this worked great.Machination
how to do it in mac, I did't find php.ini file in my xampp\php folderDisrespectable
I
22

Use command line:

mysql.exe -u USERNAME -pPASSWORD DATABASENAME < MYDATABASE.sql

where MYDATABASE.sql is your SQL file.

Invalidate answered 6/3, 2012 at 22:48 Comment(4)
how would you do this if you only had FTP access to the server?Lali
@Lali He's talking about WAMP and local. Just gave him the fastest solution to his problem taking in consideration is environment.Invalidate
aah I didn't spot the WAMP - the OP didn't mention local, but I guess most Windows server providers allow RDP, so that may be largely irrelevantLali
When using this option just make sure that you run the script in the folder where the .sql file is stored e.g C: \downloads>mysql.exe -u USERNAME -pPASSWORD DATABASENAME < MYDATABASE.sqlEncaustic
O
10
  1. Set the below values in php.ini file (C:\xampp\php\)

    • max_execution_time = 0
    • max_input_time=259200
    • memory_limit = 1000M
    • upload_max_filesize = 750M
    • post_max_size = 750M
  2. Open config.default file(C:\xampp\phpMyAdmin\libraries\config.default) and set the value as below:

    • $cfg['ExecTimeLimit'] = 0;
  3. Then open the config.inc file(C:\xampp\phpMyAdmin\config.inc). and paste below line:

    • $cfg['UploadDir'] = 'upload';
  4. Go to phpMyAdmin(C:\xampp\phpMyAdmin) folder and create folder called upload and paste your database to newly created upload folder (don't need to zip)

  5. Lastly, go to phpMyAdmin and upload your db (Please select your database in drop-down)

upload image

  1. That's all baby ! :)

*It takes lot of time.In my db(266mb) takes 50min to upload. So be patient ! *

Outflank answered 11/12, 2017 at 3:31 Comment(1)
Thanks, i always come back to this answer after i install XamppJasun
C
7

If you are using MySQL in Xampp then do the steps below.

Find the following in XAMPP control panel>Apach-Config> PHP (php.ini) file

  • post_max_size = 8M

  • upload_max_filesize = 2M

  • max_execution_time = 30
  • ut_time = 60enter code here memory_limit = 8M

And change their sizes according to your need. I'm using these values

post_max_size = 30M
upload_max_filesize = 30M
max_execution_time = 4500
max_input_time = 4500
memory_limit = 850M
Coridon answered 10/4, 2017 at 3:13 Comment(1)
user friendly solutionPriestess
D
5

For ubuntu 14.04 use this:

  1. Open php.ini using gedit or nano:

    sudo gedit /etc/php5/apache2/php.ini
    
  2. Find upload_max_size then replace this single line with these lines:

    max_execution_time = 259200
    max_input_time = 259200
    memory_limit = 1000M
    upload_max_filesize = 750M
    post_max_size = 750M
    
  3. Save php.ini and close editor

  4. Restart apache2:

    sudo service apache2 restart
    
  5. Now open localhost://phpmyadmin/ in browser and upload your database.sql

Disproportionation answered 9/6, 2016 at 10:4 Comment(1)
Thank you, it helped. I have Ubuntu 18.04 and for me path to php.ini was /etc/php/7.2/apache2/php.iniLardner
L
4

Another option that nobody here has mentioned yet is to do a staggered load of the database using a tool like BigDump to work around the limit. It's a simple PHP script that loads a chunk of the database at a time before restarting itself and moving on the the next chunk.

Lali answered 6/3, 2012 at 22:54 Comment(0)
V
1

You no need to edit php.ini or any thing. I suggest best thing as Just use MySQL WorkBench.

JUST FOLLOW THE STEPS.

Install MySQL WorkBench 6.0

And In "Navigation panel"(Left side) there is option call 'Data import' under "MANAGEMENT". Click that and [follow steps below]

  1. click Import Self-Contained File and choose your SQL file
  2. Go to My Document and create folder call "dump"[simple].
  3. now you ready to upload file. Click IMPORT Button on down.
Venusian answered 9/3, 2015 at 4:19 Comment(0)
P
1

to import big database into phpmyadmin there are two ways 1 increase file execution size from php.ini 2 use command line to import big database.

Punitive answered 20/10, 2016 at 10:26 Comment(0)
I
1

You can also try compressing (zipping) the file. It sometimes works for me if I can't get to php.ini for phpmyadmin. If zipping reduces the file size below the maximum file size, it just might work!

Inobservance answered 28/1, 2017 at 14:36 Comment(0)
C
0

You have three options:

  • Use another way to get the file on the server, and use a mysql client on the server
  • Use another client to connect to the server and load the data
  • Change your PHP settings to allow such huge files. Don't forget to increment the execution time as well.
Crossquestion answered 6/3, 2012 at 22:50 Comment(0)
C
0

If you do not want to change the settings or play with command line. There is option to compress the file and upload in phpMyAdmin. It should bring down the size considerably.

Charbonnier answered 14/1, 2021 at 1:54 Comment(0)
A
0

Just to put this here as I just updated my databases in xampp after several tries and reading the answers here. I used the Xampp 7.4 I tried to edit the ExecTimeLimit variable in config.default.php but still kept timing out and finally when I looked at the code I realized that if you put it to 0 it ill still default to 300. So you need to put it to actual high value to have a longer timeout.

 /**
 * @param array<int|string, mixed> $settings
 *
 * @psalm-return 0|positive-int
 */
private function setExecTimeLimit(array $settings): int
{
    if (! isset($settings['ExecTimeLimit'])) {
        return 300;
    }

    $execTimeLimit = (int) $settings['ExecTimeLimit'];

    return $execTimeLimit >= 0 ? $execTimeLimit : 300;
}
Averroism answered 12/4, 2023 at 14:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.