# phpMyAdmin Quick Start Guide

## Quick Setup (Copy & Paste)

```bash
# 1. Navigate to project directory
cd /opt/app/backend/lottery-be

# 2. Load database password
source scripts/load-db-password.sh

# 3. Start phpMyAdmin
docker-compose -f docker-compose.prod.yml up -d phpmyadmin

# 4. Verify it's running
docker ps | grep phpmyadmin

# 5. Open firewall port
sudo ufw allow 8081/tcp
sudo ufw reload

# 6. Get your VPS IP (if you don't know it)
hostname -I | awk '{print $1}'
```

## Access phpMyAdmin

**URL**: `http://YOUR_VPS_IP:8081`

**Login Credentials**:
- **Server**: `db` (or leave default)
- **Username**: `root`
- **Password**: Get it with: `grep SPRING_DATASOURCE_PASSWORD /run/secrets/lottery-config.properties`

## Security: Restrict Access to Your IP Only

```bash
# Get your current IP
curl ifconfig.me

# Remove open access
sudo ufw delete allow 8081/tcp

# Allow only your IP (replace YOUR_IP with your actual IP)
sudo ufw allow from YOUR_IP to any port 8081

# Reload firewall
sudo ufw reload
```

## Verify Everything Works

```bash
# Check container is running
docker ps | grep phpmyadmin

# Check logs
docker logs lottery-phpmyadmin

# Test connection from browser
# Open: http://YOUR_VPS_IP:8081
```

## Common Issues

**Container won't start?**
```bash
# Make sure password is loaded
source scripts/load-db-password.sh
echo $DB_ROOT_PASSWORD

# Restart
docker-compose -f docker-compose.prod.yml restart phpmyadmin
```

**Can't access from browser?**
```bash
# Check firewall
sudo ufw status | grep 8081

# Check if port is listening
sudo netstat -tlnp | grep 8081
```

**Wrong password?**
```bash
# Get the correct password
grep SPRING_DATASOURCE_PASSWORD /run/secrets/lottery-config.properties
```

## Full Documentation

See `PHPMYADMIN_SETUP.md` for detailed instructions and troubleshooting.

