# Self-host MySQL with phpMyAdmin

> A MySQL 8.4 server paired with the phpMyAdmin web console, already wired together. The database is not published on the host, so other services in this project reach it at db:3306. Sign in to phpMyAdmin as root with the generated root password.

- Page: https://levelrail.com/templates/mysql-phpmyadmin/
- JSON: https://levelrail.com/templates/mysql-phpmyadmin.json
- Category: Database Tools
- Licence: GPL-2.0-or-later (Copyleft license)
- Source: https://github.com/phpmyadmin/phpmyadmin
- Upstream docs: https://docs.phpmyadmin.net/en/latest/setup.html#docker

## Requirements
- Memory: about 768 MiB
- amd64: unknown, arm64: unknown
- Needs configuration before start: no
- Pinned image tag: 8.4.13

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| db | mysql | 8.4.13 | none | mysql_data -> /var/lib/mysql |
| phpmyadmin | phpmyadmin | 5.2.3 | 80 | none |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| db | MYSQL_ROOT_PASSWORD | generated |
| phpmyadmin | PMA_HOST | preset |
| phpmyadmin | PMA_PORT | preset |

## Deploy

### CLI

```bash
levelrail-cli templates install mysql-phpmyadmin --name my-mysql-phpmyadmin
```

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain db=app.example.com.

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  https://levelrail.example.com/api/v1/service-templates/mysql-phpmyadmin/install \
  -d '{
    "name": "my-mysql-phpmyadmin"
  }'
```

Create a token in the dashboard first. Name, env and domains are the request fields.

## First run
1. Open the page and sign in as root with the generated root password from the app secrets.

## Questions

### Can I deploy MySQL with phpMyAdmin on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for MySQL with phpMyAdmin, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image mysql:8.4.13, phpmyadmin:5.2.3 is what you deploy there.

Self-host MySQL with phpMyAdmin, MySQL with phpMyAdmin docker compose file, deploy MySQL with phpMyAdmin on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
