Metabase is a self-hosted business intelligence tool that lets non-technical users explore data and build dashboards by connecting directly to your existing databases — without writing SQL.
Prerequisites
- Docker Engine installed
- An existing database (MySQL, PostgreSQL, etc.) to connect to
- 2 vCPU, 2 GB RAM minimum
Step 1 — Run Metabase
docker run -d \
--name metabase \
--restart unless-stopped \
-p 3000:3000 \
-v metabase_data:/metabase-data \
-e MB_DB_FILE=/metabase-data/metabase.db \
metabase/metabase:latest
Step 2 — Allow the Port Through the Firewall
sudo ufw allow 3000/tcp
Step 3 — Access Metabase
http://YOUR_SERVER_IP:3000
Step 4 — Complete Initial Setup
Create an administrator account and connect your first data source when prompted.
Step 5 — Connect to Your Application Database
Provide connection details for your existing MySQL/PostgreSQL database — ideally using a read-only database user dedicated to Metabase, not your application's own credentials:
CREATE USER 'metabase'@'%' IDENTIFIED BY 'CHANGE_ME_STRONG_PASSWORD';
GRANT SELECT ON myapp.* TO 'metabase'@'%';
FLUSH PRIVILEGES;
Step 6 — Restrict Database Access to Metabase's Server Only
If Metabase and the database are on different servers, restrict at the firewall level:
sudo ufw allow from METABASE_SERVER_IP to any port 3306
Using a Persistent Database for Metabase's Own Metadata (Recommended for Production)
By default Metabase uses an embedded H2 database. For production, use PostgreSQL instead for better reliability:
docker run -d \
--name metabase \
--restart unless-stopped \
-p 3000:3000 \
-e MB_DB_TYPE=postgres \
-e MB_DB_DBNAME=metabase \
-e MB_DB_PORT=5432 \
-e MB_DB_USER=metabase \
-e MB_DB_PASS=CHANGE_ME \
-e MB_DB_HOST=YOUR_POSTGRES_HOST \
metabase/metabase:latest
Building Your First Dashboard
- Click New → Question to explore data visually without SQL
- Save questions and combine them into a Dashboard
- Set up automated email/Slack reports for dashboards on a schedule
Adding HTTPS
See How to Install Nginx Proxy Manager with Docker to route a domain to port 3000 with SSL.
Common Errors
Slow query performance in Metabase — ensure appropriate indexes exist on the underlying database tables Metabase queries frequently; see How to Tune MySQL/MariaDB Performance for a VPS.
Can't connect to the database — verify network connectivity and firewall rules between Metabase and the database server specifically.
Best Practices
- Always connect with a dedicated, read-only database user — never Metabase's own admin credentials for the source data
- Use PostgreSQL (not the default embedded database) for Metabase's own metadata in production
- Restrict database network access to only Metabase's specific server
Continue Reading
- Database Security Checklist: Protecting MySQL, PostgreSQL & MongoDB
- How to Install and Secure MySQL 8 on Ubuntu & Debian
- How to Install Nginx Proxy Manager with Docker
Browse more articles in Popular Self-Hosted Applications.
