To add phpMyAdmin to a Laravel Docker setup, add a phpmyadmin service to your docker-compose.yml that uses the official phpmyadmin image, point it at your MySQL service with PMA_HOST, publish a local port such as 8080, and start the stack. You can then open http://localhost:8080 and browse your Laravel tables. This guide shows the full compose file and how to keep it safe.
phpMyAdmin is a web interface for MySQL and MariaDB. In development it saves you from typing SQL for quick checks of migrations, seeders and queued job tables.
What do I need before I start?
- Docker and Docker Compose installed.
- A Laravel 13 project (PHP 8.3 or newer) already running in containers with a MySQL service. If you do not have that yet, start from a compose file with an app service and a
mysqlservice. - The database credentials your Laravel
.envuses.
Step 1: What does the compose file look like?
Here is a minimal file with a database and phpMyAdmin. Your PHP service stays as it is; it is left out to keep the example short.
services:
db:
image: mysql:8.4
environment:
MYSQL_DATABASE: laravel
MYSQL_USER: laravel
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: root-secret
volumes:
- db_data:/var/lib/mysql
networks:
- app
phpmyadmin:
image: phpmyadmin:latest
depends_on:
- db
environment:
PMA_HOST: db
PMA_PORT: 3306
ports:
- "8080:80"
networks:
- app
volumes:
db_data:
networks:
app:I have not started these containers for this article, so verify the image tags you pick against the current tags on Docker Hub. Pinning a specific version is safer than latest.
PMA_HOST is the service name of the database. Containers on the same Compose network reach each other by service name, so you never use localhost inside a container to reach another container.
Step 2: How do I start it?
docker compose up -d
docker compose psOpen http://localhost:8080. Sign in with the MYSQL_USER and MYSQL_PASSWORD from the compose file. You should see the laravel database.
Step 3: How do I make Laravel use the same database?
In Laravel's .env, the host must be the compose service name:
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=secretThen run migrations inside the app container:
docker compose exec app php artisan migrateRefresh phpMyAdmin and the new tables appear. Replace app with the name of your PHP service.
Can I log in without typing credentials?
The image also supports setting a user and password so the login form is skipped. That is convenient on a laptop but unsafe on any server, because anyone who can reach the port gets full access. Keep the login form.
How do I upload large SQL files?
Import is limited by PHP's upload limits. The image supports an UPLOAD_LIMIT environment variable. Add it under the phpmyadmin service, for example UPLOAD_LIMIT: 128M, then recreate the container.
How do I keep phpMyAdmin safe?
- Use it for local development only. Do not publish port 8080 on a production server.
- If you must reach it on a remote host, bind it to localhost with
"127.0.0.1:8080:80"and use an SSH tunnel. - Never use the MySQL root account for day-to-day browsing. Use the app user.
- Do not commit real passwords. Move them to a
.envfile used by Compose. - Stop it when you are not using it:
docker compose stop phpmyadmin.
What are the common mistakes?
- Using
localhostasPMA_HOST. Inside the container that is phpMyAdmin itself. Use the service name. - Port already in use. If 8080 is taken, change the left side, for example
"8081:80". - Connecting before MySQL is ready. The first start initialises the data directory and can take a few seconds. Wait and refresh.
- Changing the password after the first run. MySQL only applies
MYSQL_PASSWORDwhen it creates the volume. Remove the volume withdocker compose down -v(this deletes data) or change it inside MySQL. - Different networks. If the services are not on the same network, the name does not resolve.
How do I verify the setup?
docker compose psshowsdbandphpmyadminrunning.- The login page loads at port 8080.
- After
php artisan migrate, themigrationsanduserstables are listed.
FAQ
Is phpMyAdmin or Adminer better for Laravel Docker?
phpMyAdmin has more MySQL features. Adminer is a single lightweight page that also supports PostgreSQL and SQLite. Pick the one that matches your databases.
Does phpMyAdmin work with MariaDB?
Yes. Point PMA_HOST at the MariaDB service.
Why can I log in but see no Laravel tables?
You have not run migrations yet, or Laravel points at a different database. Check DB_DATABASE and run php artisan migrate.



