For production deployments, we strongly recommend using PostgreSQL as your Metabase application database.
Supported databases
Metabase supports the following databases for storing application data:- PostgreSQL (recommended for production)
- MySQL or MariaDB (also works for production)
- H2 (default for local demos - avoid in production)
PostgreSQL (recommended)
PostgreSQL is the recommended database for production Metabase deployments. Metabase supports PostgreSQL versions from the oldest supported version through the latest stable version.Create the database
First, create an empty PostgreSQL database for Metabase:Configure with environment variables
- Individual parameters
- Connection URI
- URI with separate credentials
Set each connection parameter separately:
Docker configuration
For Docker deployments, pass environment variables with the-e flag:
SSL configuration
For PostgreSQL connections with SSL certificate validation:MySQL or MariaDB
While we recommend PostgreSQL, MySQL and MariaDB are also supported for production deployments.Version requirements
- MySQL: version 8.0.17 or higher
- MariaDB: version 10.2.2 or higher
- Character set:
utf8mb4is required
ApsaraDB MySQL is not supported. Use ApsaraDB PostgreSQL instead.
Create the database
Create a MySQL database with the correct character set:Configure with environment variables
H2 database (development only)
By default, Metabase ships with an embedded H2 database for easy demos on your local machine. If you don’t provide environment variables specifying a production database, Metabase will create an H2 database in the same directory as the JAR file.H2 database files
You can see the H2 database files in your Metabase directory:Custom H2 location
To use an H2 database file in a specific directory:H2 automatically appends
.mv.db or .h2.db to the path you specify. Exclude these extensions in MB_DB_FILE.Key environment variables
Database type:
postgres, mysql, or h2Name of the Metabase application database
Database port (5432 for PostgreSQL, 3306 for MySQL)
Database username
Database password
Database hostname or IP address
Full JDBC connection string (overrides individual parameters)
Path to H2 database file (H2 only)
Cloud database services
Amazon RDS
Metabase works well with Amazon RDS for PostgreSQL or MySQL. Follow AWS best practices for:- Automated backups
- Multi-AZ deployments for high availability
- Parameter groups for performance tuning
- Security groups for network access control
Creating an RDS instance
For guidance on creating an RDS database specifically for Metabase, see our AWS RDS setup guide.Troubleshooting
Connection timeout
If you experience connection timeouts, especially over SSH tunnels:Query timeout
For long-running queries during migrations or heavy usage:SSL certificate issues
If you can’t enable certificate validation, you can temporarily enableNonValidatingFactory (not recommended):
Migrating from H2
If you’ve been using the default H2 database and want to migrate to a production database without losing your data:Migrate from H2 to production
Learn how to migrate your H2 data to PostgreSQL or MySQL
Next steps
Environment variables
View all available configuration options
Backing up Metabase
Set up regular backups of your application database
Running on Docker
Deploy Metabase with Docker and database configuration
Upgrading Metabase
Learn how to safely upgrade your Metabase instance