> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-docs-scavio-google-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Async MySQL

> Persist Agno sessions and other data asynchronously in MySQL.

`AsyncMySQLDb` stores Agent, Team, and Workflow sessions, memories, knowledge, evaluations, and traces asynchronously in [MySQL](https://www.mysql.com/).

## Usage

Install the `sqlalchemy`, `asyncmy`, and `openai` packages:

```shell theme={null}
uv pip install sqlalchemy asyncmy openai
```

```python async_mysql_for_agent.py theme={null}
from agno.agent import Agent
from agno.db.mysql import AsyncMySQLDb

db_url = "mysql+asyncmy://ai:ai@localhost:3306/ai"

db = AsyncMySQLDb(db_url=db_url)
agent = Agent(db=db)
```

Use async methods such as `Agent.arun()` and `Agent.aprint_response()` with this database.

### Run MySQL

Install [Docker Desktop](https://docs.docker.com/get-started/get-docker/), then start MySQL on port `3306`:

```bash theme={null}
docker run -d \
  --name mysql \
  -e MYSQL_ROOT_PASSWORD=ai \
  -e MYSQL_DATABASE=ai \
  -e MYSQL_USER=ai \
  -e MYSQL_PASSWORD=ai \
  -p 3306:3306 \
  mysql:8
```

## Parameters

<Snippet file="db-async-mysql-params.mdx" />
