11

I build up a docker-compose environment with apache, php7.0, mysql and also added phpmyadmin.

I tried so many times to include my own php.ini file and finally, I got to php accept it as it shown in my index.php loaded with phpinfo().

I need to load a database that weights more than 750Mb and my phpmyadmin doesn't let me import databases larger than 512Mb.

I tried to compress the db to 60Mb, but when I try to import it, it takes so long and ends up cutting the import because it took so long, leaving my db incomplete.

Even setting up my php.ini file_size limits and all that, the phpmyadmin ignores it.

This is what I've changed in php.ini:

upload_max_filesize = 1024M
post_max_size = 1024M
memory_limit = 1024M
max_execution_time = 300

My docker-compose.yml is:

version: '3.3'

services:
  php:
    build: apache-php
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./apache-php/www:/var/www/html
    links:
      - mysql
      - phpmyadmin

  mysql:
    image: mysql:5.7
    volumes:
     - ./mysql:/var/lib/mysql
    environment:
     - MYSQL_ROOT_PASSWORD=1347891743
     - MYSQL_DATABASE=database

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    links:
      - mysql
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
    ports:
      - "8080:80"
    volumes:
      - ./mysql:/var/lib/mysql

I also got a Dockerfile to run my php:

FROM php:7.0-apache

RUN docker-php-ext-install mysqli


COPY config/php.ini /usr/local/etc/php/

This is what it shows in phpmyadmin.

Phpmyadmin file size limit

A little of help would be very appreciated

Luke Marks
  • 157
  • 1
  • 1
  • 11
  • You guys answer so quickly... Anyway, I edited the post, I deleted a 0 unintentionally on 75Mb. – Luke Marks May 31 '18 at 09:36
  • No problem. If this is a load when you first start off, then you should check out https://stackoverflow.com/questions/43880026/import-data-sql-mysql-docker-container. This allows you to specify a script to run when you create the container. – Nigel Ren May 31 '18 at 09:39
  • Well, I just want a persistent database. I would run the docker-compose and start working on that database that I would only import once. – Luke Marks May 31 '18 at 09:49
  • Does this answer your question? [Docker: PhpMyAdmin has an upload limit of 2048KiB](https://stackoverflow.com/questions/58868237/docker-phpmyadmin-has-an-upload-limit-of-2048kib) – SuperDJ Oct 06 '20 at 09:43

6 Answers6

18

You can try:

Config of php.ini in phpmyadmin container in /usr/local/etc/php/

This is in .yml

phpmyadmin:
    volumes:
        - ./php-make/upload.ini:/usr/local/etc/php/php.ini

And file upload.ini

upload_max_filesize = 1280M
post_max_size = 1280M

Change any point if you want

I can do and success phpmyadmin

Jeroen
  • 544
  • 3
  • 27
17

The easy way is use the environment vars.

Inside the phpmyadmin container if you check the php conf files you can see find the file /usr/local/etc/php/conf.d/phpmyadmin-misc.ini

with this content:

allow_url_fopen=Off
max_execution_time=${MAX_EXECUTION_TIME}
max_input_vars=10000
memory_limit=${MEMORY_LIMIT}
post_max_size=${UPLOAD_LIMIT}
upload_max_filesize=${UPLOAD_LIMIT}

So you can override that value simply use environment

Your docker-composer.yml become

version: '3.3'

services:
  php:
    build: apache-php
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./apache-php/www:/var/www/html
    links:
      - mysql
      - phpmyadmin

  mysql:
    image: mysql:5.7
    volumes:
     - ./mysql:/var/lib/mysql
    environment:
     - MYSQL_ROOT_PASSWORD=1347891743
     - MYSQL_DATABASE=database

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    links:
      - mysql
    environment:
      - PMA_HOST=mysql
      - PMA_PORT=3306
      - UPLOAD_LIMIT=1024M
      - MEMORY_LIMIT=1024M
      - MAX_EXECUTION_TIME=300
    ports:
      - "8080:80"
    volumes:
      - ./mysql:/var/lib/mysql

is the same running the docker command:

docker run -e VARIABLE=VALUE ...
Zauker
  • 2,344
  • 3
  • 27
  • 36
  • 1
    I had to do a lot of searching to end up here, at what I think is the most correct answer. Using Docker conventions and configuration is much better than constantly connecting to the container and trying to edit the ini or other config files. This fixed my problem immediately, so thank you very much. – TristanZimmerman Oct 24 '21 at 21:49
3

Try this: access your phpmyadmin docker container: docker exec -it [container name or is] bash

create a php.ini in /usr/local/etc/php:

 nano /usr/local/etc/php/php.ini

(nano or vi, depends in the editor you prefer)

Add the lines you need, as example:

file_uploads = On
memory_limit = 6G
upload_max_filesize = 6G
post_max_size = 6G
max_execution_time = 6000

then reload: service apache2 reload

That worked for me!!

1

From my experience PhpMyAdmin is not the best way to import big databases. So even if you'll manage to increase memory_limit you'll still encounter long process time.

It would be better to provide init script and link it to /docker-entrypoint-initdb.d folder via docker-compose. For example:

mysql:
image: mysql:5.7
volumes:
 - ./my_directory_with_init_scripts:/docker-entrypoint-initdb.d
 - ./mysql:/var/lib/mysql
environment:
 - MYSQL_ROOT_PASSWORD=1347891743
 - MYSQL_DATABASE=database

From here you may see that it scans /docker-entrypoint-initdb.d folder for sutable file (including *.sql) and processes them. So just put your SQL dump file in linked volume and it's done.

If you still need to increase php memory_limit, then probably you can set PMA specific settings using /etc/phpmyadmin/config.user.inc.php. More information in PMA docs and in PMA docker image readme.

Djengobarm
  • 398
  • 3
  • 7
  • I ended doing a manual import connecting directly to the mysql container. I tried before your solution but I didn't understand really well your instructions. Creating a script inside a folder and when I execute the docker-compose, will execute a script that will search for a *.sql? – Luke Marks May 31 '18 at 11:31
  • You need to put sql dump file with your databse in that folder. You should also check that it includes "CREATE database" query. After that just rebuild containers and everything should work automatically. – Djengobarm May 31 '18 at 12:31
0

You can config file "phpmyadmin-misc.ini" in docker container

  1. Check merged directory.
  • docker inspect phpmyadmin

    "MergedDir": "/var/lib/docker/overlay2/e703e63ddf58c0decebd292eabaf8fe2c7eef49eafa390d7f7cc971f523fb0a8/merged",

  1. Edit file

    • cd var/lib/docker/overlay2/e703e63ddf58c0decebd292eabaf8fe2c7eef49eafa390d7f7cc971f523fb0a8/merged
    • vi usr/local/etc/php/conf.d/phpmyadmin-misc.ini

Add 2 lines

upload_max_filesize = 1024M
post_max_size = 1024M
  1. Restart Docker container
  • docker restart phpmyadmin
0

You can pass the UPLOAD_LIMIT parameter into your docker run command. The phpMyAdmin container sets the default to 2mb.

You can check it on the official documentation: https://hub.docker.com/_/phpmyadmin