Evolution API requires a database to store instance data, messages, contacts, and configuration. This guide covers database setup, connection configuration, and schema management.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/EvolutionAPI/evolution-api/llms.txt
Use this file to discover all available pages before exploring further.
Supported Databases
Evolution API supports three database configurations:- PostgreSQL - Recommended for production deployments
- MySQL - Alternative for MySQL-based infrastructures
- PostgreSQL with PgBouncer - For high-concurrency deployments
Database Provider
Set the database provider in your.env file:
Database provider to use. Options:
postgresql- Standard PostgreSQL connectionmysql- MySQL/MariaDB connectionpsql_bouncer- PostgreSQL with PgBouncer connection pooling
PostgreSQL Setup
Installation
- Docker
- Ubuntu/Debian
- macOS
Use the official PostgreSQL Docker image:
Connection URI Format
Configure the PostgreSQL connection in your.env file:
evolution- Database usernameyour_password- Database passwordlocalhost- Database host (use container name in Docker)5432- PostgreSQL portevolution_db- Database nameevolution_api- Prisma schema name
Performance Tuning
For production deployments, optimize PostgreSQL configuration:MySQL Setup
Installation
- Docker
- Ubuntu/Debian
Use the official MySQL Docker image:
Connection URI Format
Configure the MySQL connection in your.env file:
PgBouncer Configuration
PgBouncer provides connection pooling for high-concurrency deployments.Setup with Docker Compose
docker-compose.yaml
Connection Configuration
Use both connection URIs when using PgBouncer:Database Migrations
Evolution API uses Prisma for database schema management.Environment Setup
Generate Prisma Client
Generate the Prisma client for your database provider:prisma/postgresql-schema.prismafor PostgreSQLprisma/mysql-schema.prismafor MySQL
Run Migrations
- Development
- Production
For development environments:This creates migration files and applies them to the database.
Docker Automatic Migrations
When using the official Docker image, migrations run automatically on startup:deploy_database.sh script:
- Detects the database provider from
DATABASE_PROVIDER - Generates the correct Prisma client
- Runs pending migrations
- Starts the application
Database Schema
Evolution API’s database schema includes tables for:Core Tables
Instance - WhatsApp instance informationIntegration Tables
- Webhook - Webhook configurations
- Chatwoot - Chatwoot CRM integration
- Typebot - Typebot chatbot integration
- OpenaiBot - OpenAI chatbot integration
- Dify - Dify AI integration
- Rabbitmq - RabbitMQ event configuration
- Sqs - AWS SQS event configuration
- Websocket - WebSocket event configuration
Prisma Studio
Browse and edit your database with Prisma Studio:http://localhost:5555 for database management.
Data Storage Options
Control what data is saved to the database:.env
Disabling data storage options reduces database size but limits API functionality like message history and contact retrieval.
Client Name Separation
When running multiple Evolution API installations on the same database:Backup and Restore
PostgreSQL Backup
MySQL Backup
Automated Backups
Set up automated daily backups with cron:Troubleshooting
Connection refused errors
Connection refused errors
If Evolution API cannot connect to the database:
-
Verify the database is running:
- Check connection URI format is correct
- Verify username and password
-
Ensure the database exists:
- Check firewall rules allow connections on port 5432/3306
Migration errors
Migration errors
If migrations fail:
-
Ensure
DATABASE_PROVIDERis set correctly: -
Verify database connection before running migrations:
-
Check migration files exist:
-
Reset migrations (development only):
Authentication failed errors
Authentication failed errors
For authentication errors:
- Verify username and password in connection URI
-
Check user permissions:
-
Ensure user has necessary privileges:
Slow query performance
Slow query performance
To optimize query performance:
-
Enable query logging:
-
Analyze slow queries:
- Create indexes for frequently queried columns
- Increase shared_buffers and effective_cache_size
- Consider using PgBouncer for connection pooling
Security Best Practices
- Use strong passwords - Generate random passwords for database users
- Limit network access - Bind database to localhost or private network only
- Enable SSL/TLS - Use encrypted connections in production
- Regular backups - Implement automated backup strategies
- Update regularly - Keep database software up to date
- Monitor access - Enable and review database audit logs
- Principle of least privilege - Grant only necessary permissions
Next Steps
Environment Variables
Configure all Evolution API settings
Docker Deployment
Deploy Evolution API with Docker Compose