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

# MySQL Storage

Agno supports using MySQL as a storage backend for Agents using the `MySQLStorage` class.

## Usage

### Run MySQL

Install [docker desktop](https://docs.docker.com/desktop/install/mac-install/) and run **MySQL** on port **3306** using:

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

```python postgres_storage_for_agent.py theme={null}
from agno.storage.mysql import MySQLStorage

db_url = "mysql+pymysql://agno:agno@localhost:3306/agno"

# Create a storage backend using the Postgres database
storage = MySQLStorage(
    # store sessions in the agno.sessions table
    table_name="agent_sessions",
    # db_url: Postgres database URL
    db_url=db_url,
)

# Add storage to the Agent
agent = Agent(storage=storage)
```

## Params

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

## Developer Resources

* View [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/storage/mysql_storage/mysql_storage_for_agent.py)
