How to Self-Host phpMyAdmin with Docker Compose
What Is phpMyAdmin?
phpMyAdmin is the most widely used web-based administration tool for MySQL and MariaDB databases. It provides a full GUI for managing databases, tables, columns, relations, indexes, users, and permissions. It supports SQL query execution, data import/export in multiple formats, and visual database design. Available at phpmyadmin.net.
Updated March 2026: Verified with latest Docker images and configurations.
Prerequisites
- A Linux server (Ubuntu 22.04+ recommended)
- Docker and Docker Compose installed (guide)
- 512 MB of free RAM (minimum)
- A MySQL or MariaDB database server (included in the config below)
Docker Compose Configuration
Create a docker-compose.yml file:
services:
phpmyadmin:
image: phpmyadmin:5.2.3-apache
container_name: phpmyadmin
restart: unless-stopped
ports:
- "8080:80"
environment:
# MySQL/MariaDB server hostname
PMA_HOST: db
# MySQL server port (default: 3306)
PMA_PORT: 3306
# Allow connecting to any MySQL server (set to empty to enable arbitrary server input)
# PMA_ARBITRARY: 1
# Upload limit for SQL imports (default: 2M)
UPLOAD_LIMIT: 256M
# Session timeout in seconds (default: 1440 = 24 minutes)
PMA_SESSION_EXPIRY: 3600
depends_on:
db:
condition: service_healthy
networks:
- pma-net
db:
image: mariadb:11.7
container_name: phpmyadmin-mariadb
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: change-this-root-password
MARIADB_DATABASE: myapp
MARIADB_USER: appuser
MARIADB_PASSWORD: change-this-app-password
volumes:
- mariadb_data:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 5
networks:
- pma-net
volumes:
mariadb_data:
networks:
pma-net:
Start the stack:
docker compose up -d
Initial Setup
- Open
http://your-server-ip:8080in your browser - Log in with the MySQL/MariaDB credentials:
- Username:
root(orappuserfor limited access) - Password: the password set in
MARIADB_ROOT_PASSWORDorMARIADB_PASSWORD
- Username:
- You’ll see the phpMyAdmin dashboard with your databases listed in the left sidebar
No additional setup wizard is required.
Configuration
Arbitrary Server Mode
To connect to multiple MySQL servers from a single phpMyAdmin instance, enable arbitrary server mode:
environment:
PMA_ARBITRARY: 1
This shows a “Server” field on the login page where you can enter any MySQL hostname.
Import/Export Limits
The default upload limit is 2 MB. For large database imports, increase it:
environment:
UPLOAD_LIMIT: 512M
This sets both PHP’s upload_max_filesize and post_max_size.
Custom Configuration
Mount a custom config.user.inc.php for advanced settings:
volumes:
- ./config.user.inc.php:/etc/phpmyadmin/config.user.inc.php:ro
Example custom config:
<?php
$cfg['ShowDatabasesNavigationAsTree'] = true;
$cfg['MaxNavigationItems'] = 250;
$cfg['NavigationTreeEnableGrouping'] = true;
$cfg['SendErrorReports'] = 'never';
Environment Variables Reference
| Variable | Default | Purpose |
|---|---|---|
PMA_HOST | — | MySQL server hostname |
PMA_PORT | 3306 | MySQL server port |
PMA_ARBITRARY | 0 | Allow arbitrary server connections |
PMA_ABSOLUTE_URI | — | Full URL for reverse proxy setups |
UPLOAD_LIMIT | 2M | Max upload size for SQL imports |
PMA_SESSION_EXPIRY | 1440 | Session timeout in seconds |
MEMORY_LIMIT | 512M | PHP memory limit |
MAX_EXECUTION_TIME | 600 | PHP max execution time in seconds |
Reverse Proxy
When running behind a reverse proxy, set PMA_ABSOLUTE_URI to your public URL:
environment:
PMA_ABSOLUTE_URI: https://db.yourdomain.com/
For Nginx Proxy Manager:
- Forward Hostname:
phpmyadmin - Forward Port:
80 - Enable SSL with Let’s Encrypt
For detailed setup, see Reverse Proxy Setup.
Backup
phpMyAdmin itself stores no persistent data. Back up your MariaDB database:
docker exec phpmyadmin-mariadb mariadb-dump -u root -p --all-databases > backup.sql
You can also use phpMyAdmin’s built-in Export feature to download database dumps through the web UI. For automated backups, see Backup Strategy.
Troubleshooting
”Access denied for user” after correct password
Symptom: Login fails with “Access denied” despite correct credentials.
Fix: MariaDB 11+ defaults to unix_socket authentication for root. Either log in as the non-root user (appuser) or update the root auth method:
ALTER USER 'root'@'%' IDENTIFIED VIA mysql_native_password USING PASSWORD('your-password');
FLUSH PRIVILEGES;
Large SQL import fails or times out
Symptom: Importing a large .sql file hangs or returns an error.
Fix: Increase UPLOAD_LIMIT, MEMORY_LIMIT, and MAX_EXECUTION_TIME:
environment:
UPLOAD_LIMIT: 1G
MEMORY_LIMIT: 1024M
MAX_EXECUTION_TIME: 3600
For very large databases (>1 GB), use the command line instead: docker exec -i phpmyadmin-mariadb mariadb -u root -p < backup.sql
phpMyAdmin session expires too quickly
Symptom: You get logged out frequently while working.
Fix: Increase PMA_SESSION_EXPIRY (in seconds). Default is 1440 (24 minutes):
environment:
PMA_SESSION_EXPIRY: 7200
Resource Requirements
- RAM: ~50-100 MB idle, ~200 MB under heavy query load
- CPU: Low
- Disk: ~100 MB for the Docker image, no persistent storage needed
Verdict
phpMyAdmin remains the gold standard for MySQL/MariaDB web administration. Its import/export capabilities, visual query builder, and user management features are unmatched in the MySQL ecosystem. If you manage multiple database types, choose Adminer instead — it supports MySQL, PostgreSQL, SQLite, and more from a single lightweight interface. If you primarily use PostgreSQL, pgAdmin is the dedicated tool for that. For MySQL/MariaDB-only environments, phpMyAdmin is the clear choice.
Frequently Asked Questions
How does phpMyAdmin compare to Adminer?
phpMyAdmin is purpose-built for MySQL and MariaDB with deep features — visual query builder, multi-table operations, extensive import/export formats, and user permission management. Adminer is a lightweight single-file tool that supports MySQL, PostgreSQL, SQLite, MongoDB, and more. Choose phpMyAdmin for dedicated MySQL/MariaDB administration with maximum feature coverage. Choose Adminer if you manage multiple database types and want a minimal footprint.
Can phpMyAdmin connect to remote database servers?
Yes. Set the PMA_HOST environment variable to your remote MySQL/MariaDB server’s hostname or IP. For multiple servers, use PMA_HOSTS with a comma-separated list. You can also set PMA_ARBITRARY=1 to let users specify the server at login time — useful if you manage databases across multiple hosts.
Is phpMyAdmin secure enough for production?
phpMyAdmin itself is mature and well-audited, but exposing it to the internet requires precautions. Always run it behind a reverse proxy with HTTPS, restrict access by IP or use an authentication proxy like Authelia or Authentik. Consider binding it only to localhost or your Docker network. Never expose port 8080 directly to the public internet.
Can phpMyAdmin import and export large databases?
By default, PHP limits uploads to a few megabytes. Increase UPLOAD_LIMIT and MEMORY_LIMIT in the environment variables for larger imports. For databases over 1 GB, use the command line instead: docker exec -i container mariadb -u root -p < dump.sql. phpMyAdmin exports in SQL, CSV, JSON, XML, and other formats.
Does phpMyAdmin support multiple database connections simultaneously?
Yes. Configure PMA_HOSTS with comma-separated hostnames to connect to multiple MySQL/MariaDB instances. phpMyAdmin shows a server selector on the login page. Each connection is independent — you can run queries, manage users, and import/export data on each server separately.
How much RAM does phpMyAdmin need?
phpMyAdmin is extremely lightweight — 50–100 MB idle, rarely exceeding 200 MB even under heavy query loads. It’s a PHP application served by Apache, so the overhead is minimal. The database servers it connects to use the real resources, not phpMyAdmin itself. It runs comfortably on the smallest VPS or a Raspberry Pi.
Related
Get self-hosting tips in your inbox
Get the Docker Compose configs, hardware picks, and setup shortcuts we don't put in articles. Weekly. No spam.
Comments