270

I have a WordPress production website.

I've exported the database by the following commands: select database > export > custom > select all tables > select .zip compression > 'Go'

I've downloaded the file which is example.sql.zip but when I upload to my localhost I get this error: phpMyAdmin - Error > Incorrect format parameter

I've tried to export with other formats and I get the same error.

I've tried with other SQL Databases and it exports/ imports just fine.

What could it be? A corrupt database or other?

Thanks

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
Henry
  • 5,195
  • 7
  • 21
  • 34

21 Answers21

656

This issue is not because of corrupt database but rather the PHP upload size limit. It is suggested to increase the values of the following variables in php.ini:

upload_max_filesize=64M
post_max_size=64M

You may also want to increase the max_exection_time to a longer value for larger databases so it does not timeout while uploading.

Save you changes to the file and restart your PHP server.

Skully
  • 2,882
  • 3
  • 20
  • 31
Pooja Mistry
  • 6,835
  • 1
  • 13
  • 8
  • 2
    Thanks for the idea which was a good one, however it still didn't work. I'm really out of ideas here... – Henry Jun 09 '18 at 05:49
  • 34
    Might as well increase the `max_exection_time` also because the database could be large and triggger a timeout. – Whip Jul 24 '18 at 05:23
  • 1
    that's correct.. both config together is a correct answer. not first item. I try to resolve by first item and cant. but when do second solved. thanks, StackOverflow thanks pooja. – saber tabatabaee yazdi Oct 11 '18 at 17:55
  • 3
    [***See this question also***](https://stackoverflow.com/questions/11691767/where-does-mamp-keep-its-php-ini) if you're using MAMP because you might have a hard time finding `php.ini`, like I did. – GDP2 May 07 '19 at 23:34
  • on linux to get your file size in M `ls -l --block-size=M` – PhilWilliammee Jul 26 '20 at 12:40
  • Thank you. I did this on mamp and then restarted mamp. Everything is working perfect now. – Kustom Jul 28 '20 at 16:06
  • I had the same problem, I was trying to upload the sql file which has very high file size about ~18MB but when I compressed the file it reduces to ~4 MB which fixed the problem. Thank you. – Surendra Shrestha May 03 '21 at 03:34
  • @VeeK you could correct your comment to "max_execution_time", then i delete mine :) – Diego Frehner Jul 02 '21 at 16:57
  • 2
    Jbtw, the correct spelling from @Whip comment is `max_execution_time` – Osama Dar Oct 13 '21 at 01:33
  • How can this be done if you spin up a docker container??? – klewis Nov 19 '21 at 21:51
  • Yes this is old... There are 100 similar answers in a dozen questions. The missing piece for me after the changes were to RESTART THE SERVER. Simple, but essential. Thank you. – mseifert Aug 24 '22 at 09:04
97

Compress your .sql file, and make sure to name it .[format].[compression], i.e. database.sql.zip.

As noted above, PhpMyAdmin throws this error if your .sql file is larger than the Maximum allowed upload size -- but, in my case the maximum was 50MiB despite that I had set all options noted in previous answers (look for the "Max: 50MiB" next to the upload button in PhpMyAdmin).

Design.Garden
  • 3,607
  • 25
  • 21
  • 4
    This worked for me. I had `max_execution_time=0` and `post_max_size=100M`, but an 80 MB file still gave an error. Zipping as `file.sql.zip` did the trick. – jogi99 Nov 20 '18 at 17:15
  • This solved my problem. My sql file was only slightly above the maximal size, but note that compressing can reduce the size significaltly: In my case 16-fold. – Paul Mar 12 '19 at 10:22
  • This helped me. I had 100MB set in php.ini and the file was generating the error at 46% of the upload, which was 43MB. I zipped it and no problem. – Doug Wolfgram Apr 17 '19 at 01:30
  • Simple and effective! – Antoine Mouquod Nov 26 '20 at 13:14
  • Actually, this issue because of Database Size. – Thirsty Six May 27 '21 at 13:50
  • Very Helpful. Be blessed. – Wilson Jun 10 '22 at 14:05
  • Thank you - all the other answers are right, but if you somehow have server limits and the max upload size can't be changed in spite of setting it in options, this is an amazing (and hard-to-have-known) solution. – limco Sep 05 '22 at 05:48
63

For me, adjusting the 2 values was not enough. If the file is too big, you also need to adjust the execution time variables.

First, ../php/php.ini

upload_max_filesize=128M
post_max_size=128M
max_execution_time=1000

Then, ../phpMyAdmin\libraries\config.default.php

$cfg['ExecTimeLimit'] = 1000;

This did the trick for me. The variables can be choosen differently of course. Maybe the execution time has to be even higher. And the size depends on your filesize.

Martin N
  • 631
  • 5
  • 4
31

None of these answers worked for me. I had to use the command line:

mysql -u root db_name < db_dump.sql
SET NAMES 'utf8';
SOURCE db_dump.sql;

Done!

Pedro Araujo Jorge
  • 642
  • 2
  • 9
  • 19
21

If you use docker-compose just set UPLOAD_LIMIT

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
        UPLOAD_LIMIT: 1G
Eugene
  • 991
  • 10
  • 10
  • This is the correct way, it seems, from the default phpmyadmin docker image docs. I would like to add that if one is using nginx as a proxy pass, they must set proxy_read_timeout (i.e. `proxy_read_timeout 1500`). – Tim Apr 05 '21 at 02:13
18

Just gone through the same problem when trying to import a CSV (400 MBs) and was also getting an error in red saying

Error - incorrect format parameter

Initially thought it could have been the parameters and tested again. Faster, from my previous experince with it, I realized that it was due to other reasons (size of the file, execution of script has a maximum time defined, etc).

So, I've gone to php.ini

php.ini

and changed the values from the following settings

max_execution_time = 3000
max_input_time = 120
memory_limit = 512M
post_max_size = 1500M
upload_max_filesize = 1500M 

After this modification, stoped MySQL and Apache and started them again, went to phpmyadmin trying to import. Then I reached another error

Fatal error: Maximum execution time of 300 seconds exceeded

which was fixed by simply setting in xampp/phpmyadmin/libraries/config.default.php

config.default.php

$cfg['ExecTimeLimit'] = 0;

Setting it to 0 disables execution time limits.

Then, after a while, the import happened without problems.

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
  • 3
    Worked for me. +1 for well-detailed answer, clear instructions on what to change and how to change – Hamman Samuel Jan 23 '21 at 05:29
  • You should edit `xampp\phpMyAdmin\config.inc.php` instead. The `config.default` file clearly states "DO NOT EDIT THIS FILE, EDIT config.inc.php INSTEAD" – correctsyntax Sep 09 '22 at 17:08
10

I got this error too, and I'm working with ubuntu 20.04 and PHP 8.0 so I solved the problem with these steps:

sudo nano /etc/php/8.0/apache2/conf.d/php.ini

in opened file find upload_max_filesize, post_max_size, max_input_time, max_execution_time by CTRL + w and increase the values like this:

max_execution_time = 3000
upload_max_filesize = 64M
max_input_time = 6000
upload_max_filesize = 64M

save the INI file by CTRL + o and then close that by CTRL + x.

then restart your web server by this command:

sudo service apache2 restart

NOTE: These 4 parameters are not together and you have to find them one by one.

Pejman Kheyri
  • 4,044
  • 9
  • 32
  • 39
  • `/etc/php/8.1/apache2/conf.d/(my name)_php.ini` <-- it may be a bit more in sync with the `conf.d` strategy to create a **new file** than to edit an existing one. As if to confirm, the default php.ini was moved out of there. I guess this worked for me because my file in conf.d was loaded after php.ini. – Bob Stein Nov 22 '22 at 18:07
7

Without any problems, I imported directly from the command line.

mysql -uroot -hURLServer -p DBName< filename.sql
BSMP
  • 4,596
  • 8
  • 33
  • 44
Kairat Koibagarov
  • 1,385
  • 15
  • 9
5

If you prefer to edit the file php.ini in your favorite editor than the Editor created by MAMP, you would need to stop the Servers first.

Then head to Library->Application Support->appsolute->MAMP PRO->templates->php{version_number}.ini.temp and effect any change you would want to have especially the below

max_execution_time = 3000
max_input_time = 60
memory_limit = 128M
post_max_size = 256M
upload_max_filesize 256M

And also make changes in your PHPMyAdmin if it is what you are using in Cpanel.

$cfg['ExecTimeLimit'] = 300;

Make sure you make a copy of the original file. You can navigate under conf!here

enter image description here

pensebien
  • 506
  • 4
  • 16
4

I had this problem but with a docker container (phpmyadmin users),

Solution:

  • Enter in the phpmyadmin container docker exec -it idcontainer /bin/bash
  • Move cd /usr/local/etc/php/
  • Create php.ini file
  • Modify it upload_max_filesize=128M post_max_size=128M max_execution_time=1000
  • Save and restart container.

This problem was in a Windows pc, at Linux i didnt need to do this.

Schwarz54
  • 964
  • 1
  • 9
  • 18
  • i've docker container, i agree php.ini inside /usr/local/etc/php , already php.ini but continue error incorrect format parameter when import .sql in phpmyadmin – Diego Santa Cruz Mendezú Jan 09 '21 at 05:49
  • Ensure you restart the container after changes or it not gonna work. – Schwarz54 Jan 12 '21 at 14:44
  • Diego, that was probably b/c there are additional configuration files that are read after the initial php.ini file. Look at the ones in /usr/local/etc/php.d/*.ini. https://www.php.net/configuration.file – Tim Apr 05 '21 at 02:16
4

Note: If you're using MAMP you MUST edit the file using the built-in editor.

Select PHP in the languages section (LH Menu Column) Next, in the main panel next to the default version drop-down click the small arrow pointing to the right. This will launch the php.ini file using the MAMP text editor. Any changes you make to this file will persist after you restart the servers.

Editing the file through Application->MAMP->bin->php->{choosen the version}->php.ini would not work. Since the application overwrites any changes you make.

Needless to say: "Here be dragons!" so please cut and paste a copy of the original and store it somewhere safe in case of disaster.enter image description here

pensebien
  • 506
  • 4
  • 16
user432350
  • 161
  • 9
4

On the command line use

C:\Windows\system32> mysql -u root -p

mysql> use desired_db;
mysql> source db_backup.sql;
Swaleh Matongwa
  • 698
  • 9
  • 16
3

I was able to resolve this by following the steps posted here: xampp phpmyadmin, Incorrect format parameter

Because I'm not using XAMPP, I also needed to update my php.ini.default to php.ini which finally did the trick.

3

If You are using wampp and windows 11 open folder C:\wamp64\alias\phpmyadmin.conf

update values

php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360

to

php_admin_value upload_max_filesize 1028M
php_admin_value post_max_size 1028M
php_admin_value max_execution_time 3600
php_admin_value max_input_time 3600
YasirPoongadan
  • 683
  • 6
  • 19
2

This error is caused by the fact that the maximum upload size is (Max: 2,048KiB). If your file is bigger than this, you will get an error. Zip the file and upload it again, you will not get the error.

to240
  • 381
  • 3
  • 5
1

I had this error and as I'm on shared hosting I don't have access to the php.ini so wasn't sure how I could fix it, the host didn't seem to have a clue either. In the end I emptied my browser cache and reloaded phpmyadmin and it came back!

Helen Lee
  • 39
  • 7
1

You can use xampp shell

  1. Open Xampp and click shell enter image description here

Type the following command mysql -u username -p -v database_name < "/path/file.sql"

example : username :root

      password : leave blank

database_name is the database you are importing to (create this database before importing)

Herbert
  • 75
  • 8
1

Solved! with 2 simple steps.

  1. in php.ini

    max_execution_time = 600

    max_input_time = 600

    memory_limit = 1024M

    post_max_size = 1024M

  2. my.ini

    max_allowed_packet = 1024M

Thirsty Six
  • 399
  • 1
  • 6
  • 13
0

If you can't upload import file due to big size and you can't modify parameters because you are in a shared hosting try to install on your computer HeidiSQL and load file from there.

Kike Lebowski
  • 501
  • 6
  • 6
0

This tends to occur when you change the PHP settings as mentioned here and continue to import the database without first restarting Apache. That causes the error to be triggered.

Danstan Ongubo
  • 105
  • 1
  • 8
-2

None of the above answers solved it for me.

I cant even find the 'libraries' folder in my xampp - ubuntu also.

So, I simply restarted using the following commands:

sudo service apache2 restart

and

sudo service mysql restart

Just restarted apache and mysql. Logged in phpmyadmin again and it worked as usual.

Thanks me..!!

Deepak Keynes
  • 2,291
  • 5
  • 27
  • 56