error on uploading database to phpmyadmin - sql

I'm trying to upload a 280MB database (.sql) to localhost/phpmyadmin but i keep getting this error:
Fatal error: Maximum execution time of 300 seconds exceeded in C:\wamp\apps\phpmyadmin4.04\libraries\dbi\mysqli.dbi.lib.php on line 267
It's worth mentioning that i changed the post_max_size in file php.ini to 350M, and the upload_max_filesize (also in file php.ini) to 300M. That's because my .sql file is about 300M.
How can i overcome this?
edit:
as #Duikboot suggested, i did the import via cmd, and it worked:
Go to mysql path. In my case:
cd C:\wamp\bin\mysql\mysql5.6.12\bin
then connect to your root:
mysql -u root -p -h 127.0.0.1
enter password if you have one
i'm not sure whether the next 2 steps are necessary if the .sql file has a create database query
create a new database:
create database NewDataBaseName;
use it:
use NewDataBaseName;
and finally import the file (enter full path). in my case:
source c:/testdb.sql;
note that it's a backslash (/) and not a regular slash (\)

The error message should give you a clue!!!
Maximum execution time of 300 seconds exceeded
You will need to increase the allowed execution time as well as the other changes you made.
So edit php.ini ( use the wampmanager menus to make sure you edit the correct file )
Find the parameter max_execution_time = 300 and increase to max_execution_time = 900
A better solution is to set all these value specifically for phpmyadmin only. So you dont effect the normal execution of a php script running in the browser. So set the values you changed back to what they were before you changed them, then ...
Edit \wamp\alias\phpmyadmin.conf and add these commands
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin4.0.4/"
<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
Require local
php_admin_value upload_max_filesize 300M
php_admin_value post_max_size 350M
php_admin_value max_execution_time 600
php_admin_value max_input_time 360
</Directory>

Related

Increasing file upload limit in apache httpd file

My cilent is using Apache server deployed on Linux OS. Application allows files upto 50MB but its throwing errors when uploaded more than 2MB. I searched online and found limit can be increased by below options:
post_max_size & upload_max_filesize
But these two parameters are not found in httpd file. So could anyone here please help me which values i need to set to increase file upload limit?
You don't need to do anything in your httpd file.
For increase files size you need to edit php.ini where you find this two optins :
post_max_size & upload_max_filesize
For Windows, you can find the file in the C:\xampp\php\php.ini-Folder (Windows) or in the etc-Folder (within the xampp-Folder).
Under Linux, most distributions put lampp under /opt/lampp, so the file can be found under /opt/lampp/etc/php.ini.
Find and set the following two values:
post_max_size = 100M
upload_max_filesize = 100M
Save and close the file and restart Apache server.

PHP file upload failure for large files

I am using a slightly modified version of phUploader script that works fine for small files. But when I try to upload files larger than 1MB it fails by giving this undescriptive error:
General upload failure.
Nginx error log does not show any evidence. I have set
upload_max_filesize = 200M
post_max_size = 200M
memory_limit = 128M
in the php.ini
and
client_max_body_size 200M;
in nginx.conf.
The odd thing is that the script used to work well on the same server (before an upgrade on Debian 6 server) and already works well on another Debian 6 server with the same nginx and php configs. So I'm really out of ideas and appreciate your hints.
You're getting an undescriptive error because the script you're using isn't properly displaying the actual error (line 252).
Modify the script to echo or log the value of $_FILES['file']['error'] instead of "General upload failure." Then, you should see a more appropriate error code. The PHP Manual has a section that explains what the error codes mean.

php directives in .htaccess?

I have attempted to make a few changes to php via .htaccess, yet none have yielded any results. For example:
php_value memory_limit 256M within will not activate.
Attempting to set SetEnv PHPRC /home/username/public_html/php.ini or any similar incantation, such as SetEnv PHPRC /home/username/some_path, will not work yield any difference in phpinfo. I DO see that _SERVER["PHPRC"] is indeed set, but no values are overwritten such as that noted above.
My phpinfo is as follows:
https://gist.github.com/ylluminate/08efd9a2844723631214
I'm wondering if I'm missing an apache module that's not allowing this to work as expected for a custom php.ini or phprc. Further This is an Apache 2.4.4 installation on a VPS over which I have 100% control (Linode) and using WHM + cPanel.
Since PHP 5.3 you can use .user.ini files, given that PHP is setup to run via the CGI/FastCGI SAPI.
http://php.net/configuration.file.per-user
It's a simple extension of the main php.ini and allows specifying options equivalently:
memory_limit = 256M
upload_tmp_dir = /tmp
Usually you can place one of these in the DOCUMENT_ROOT. But every directory may contain one, so options may vary per script/folder. It's meant as full alternative to Apaches/mod_php .htaccess setting directives.

How to set post_max_size on apache server with htaccess (getting internal server error)

I am trying to increase the maximum post size limit on my server.
Here is the .htaccess file:
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
However it does not seem to work and throws a 500 Internal server error.
Any ideas why this could be happening and how to overcome this?
As far as I can tell, your syntax is correct. However, the php_value Apache directive is provided by the mod_php module. If you don't run PHP as Apache module (e.g., it runs as FastCGI or with some other SAPI) that directive won't be defined, thus the 500 error.
There're many ways to change PHP settings. In practice, I've found that hosting services that run CGI often provide a custom php.ini file somewhere in your FTP account. Additionally, if you run PHP/5.3.0 or newer you can use .user.ini files. Last but not least, there's ini_set() within code.

Can I set a php.ini (upload_max_filesize) variable in .htaccess to only apply to one .php file?

I'm not sure if this is possible, but here's what I would like to do.
I have a .php script that uploads and then manipulates the file. I only want that particular .php script to be allowed to upload large files, the php.ini settings should apply for all others.
Can I edit the .htaccess file to affect only the one .php script?
In pseudo-code:
if (myPhpScript.php) {
php_value upload_max_filesize 16M
}
Thanks!
You should be able to use the Files directive in .htaccess:
<Files myPhpScript.php>
php_value upload_max_filesize 16M
</Files>
I am not sure but you could just use the function ini_set() within the php file you want to have the ini value changed. See: http://php.net/ini_set