Is it possible to set higher limits only for /phpmyadmin?

My server will host multiple shared websites, and we will frequently upload relatively large files to /phpmyadmin.

I would like to know if it is possible to set higher values specifically for /phpmyadmin without affecting the global configuration.

I don’t want to have to increase global values every time an upload is needed.

I ran some tests, and unfortunately, using only the .user.ini file with max_execution_time is not enough, since the Apache timeout and some other Nginx variables also affect the upload. For example, an upload might take up to an hour to complete.

Have you tried mysqldump instead?

I would like to keep it simple so that non-expert users can easily upload SQL files.

can’t you just upload .sql.gz?

I’d personally vote for increased limits for phpmyadmin, but i’ve only had to use phpmyadmin 3-4 times in the last 4 years I’d guess, so It’s probably not really critical.

With the depecration of mySQL workbench, I’ll probably use phpmyadmin MOAR in the future.

I did something functional, but I still need support to know if it’s secure since I’m a beginner.

I start by disabling /etc/apache2/conf.d/phpmyadmin.inc and /etc/nginx/conf.d/phpmyadmin.inc by renaming them to .bak and recreating the files without any content.

Next, I increase the limits in /etc/phpmyadmin/conf.d/01-localhost.php by adding $cfg[‘ExecTimeLimit’] = 7200;

I create a custom nginx.ssl.conf_custom for the main domain and add:

location /phpmyadmin {

    alias /usr/share/phpmyadmin; 
    
    index index.php;
	
	client_body_timeout             7200s;  
	send_timeout 		            7200s;  
	keepalive_timeout               7200s;
	
	proxy_connect_timeout           7200s;
	proxy_read_timeout              7200s;
	proxy_send_timeout              7200s;
	
	fastcgi_connect_timeout         7200s;    
	fastcgi_read_timeout            7200s;    
	fastcgi_send_timeout            7200s;    
	
	location ~ /(libraries|setup|templates|locale|config|db_structure) {
		deny   all;
		return 404;
	}


	location ~ /(.+\.(json|lock|md|bak|backup|sql|tar|gz|zip|htaccess|git)) {
		deny   all;
		return 404;
	}

	location ~ ^/phpmyadmin/(.*\.php)$ {
		include /etc/nginx/fastcgi_params;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin/$1;
		fastcgi_pass unix:/run/php/www.sock;

		fastcgi_param PHP_VALUE "memory_limit=3000M \n max_execution_time=7200 \n max_input_time=7200"; 
	}
	
}

I was in doubt whether to use fastcgi_param SCRIPT_FILENAME with /usr/share/phpmyadmin/$1 or $document_root$fastcgi_script_name, which seems to be the default.

You say that it might take an hour to upload a database. That suggests that you’re going to be pushing the limits of PHPmyadmin. I’d go along with the suggestion of uploading it with ssh, sftp and using the commandline to import it. Maybe you can create a script to make it easier for your users.
PHPmyadmin also has a facility where you can nominate an import directory, so maybe that might be useful: you could upload by sftp, and then import with phpmyadmin.
https://docs.phpmyadmin.net/en/latest/config.html#web-server-upload-save-import-directories

What kinda .SQL file takes an hour to upload?
Can’t we just use .SQL.GZ or .SQL.zip instead?

Here’s my answer from ChatGPT

Here’s a more complete list of supported file formats:

ChatGPT_Prompt
what formats can I upload via phpmyadmin?

  • .sql
  • .sql.gz

Do I have those extensions correct? What ELSE is available to execute via the Import tab (at the database level) in phpmyadmin by default?

ChatGPT_Answer

Supported Import Formats in phpMyAdmin:

  1. .sql – Standard SQL dump file
  2. .sql.gz – Gzipped SQL dump
  3. .sql.zip – Zipped SQL dump
  4. .sql.bz2 – Bzip2 compressed SQL dump
  5. .sql.xz – XZ compressed SQL dump
  6. .csv – Comma-Separated Values
  7. .xml – XML file
  8. .json – JSON file
  9. .yaml / .yml – YAML format
  10. .txt – Raw text file with SQL commands
  11. .ods – OpenDocument Spreadsheet
  12. .xls – Microsoft Excel 97-2003
  13. .xlsx – Microsoft Excel 2007+
  14. .mediawiki – MediaWiki table format
  • The maximum file size for uploads depends on the PHP settings (upload_max_filesize and post_max_size).
  • Some formats like CSV require additional configuration (such as setting delimiters).