Database
The database is a fundamental part of the Evolution API v2, responsible for storing all the application’s critical information. The API supports both PostgreSQL and MySQL, using Prisma as the ORM (Object-Relational Mapping) to facilitate interaction with these databases.
Database Choice
Evolution API v2 offers the flexibility to choose between PostgreSQL and MySQL as the database provider. The choice can be configured through the DATABASE_PROVIDER
environment variable, and connections are managed by Prisma.
Installation and Configuration
Using Docker
The easiest and fastest way to set up a database for Evolution API v2 is through Docker. Below are the instructions to configure both PostgreSQL and MySQL using Docker Compose.
PostgreSQL
To set up PostgreSQL via Docker, follow these steps:
- Download the
docker-compose.yaml
file for PostgreSQL available here. - Navigate to the directory where the file was downloaded and run the command:
- The PostgreSQL instance will be available at
localhost
on port5432
.
MySQL
To set up MySQL via Docker, follow these steps:
- Download the
docker-compose.yaml
file for MySQL available here. - Navigate to the directory where the file was downloaded and run the command:
- The MySQL instance will be available at
localhost
on port3306
.
Environment Variables Configuration
After setting up the database, define the following environment variables in your .env
file:
Local Installation
If you prefer to set up the database locally without using Docker, follow the instructions below:
PostgreSQL
- Install PostgreSQL on your machine. On Ubuntu-based systems, for example, you can use:
- Start the PostgreSQL service:
- Create a database for Evolution API v2:
MySQL
- Install MySQL on your machine. On Ubuntu-based systems, you can use:
- Start the MySQL service:
- Create a database for Evolution API v2: