Docker phpmyadmin ignoring my php.ini config
Solution 1
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
Solution 2
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 ...
Solution 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!!
Solution 4
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.
Luke Marks
Updated on June 05, 2022Comments
-
Luke Marks almost 2 years
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.
A little of help would be very appreciated
-
Luke Marks almost 6 yearsI 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?
-
Djengobarm almost 6 yearsYou 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.
-
TristanZimmerman over 2 yearsI 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.