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

# MySQL

> MySQL conversation store setup

# MySQL

MySQL support for conversation persistence.

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install "praisonaiagents[tools]"
```

## Docker Setup

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
docker run -d --name praison-mysql -p 3306:3306 \
    -e MYSQL_ROOT_PASSWORD=praison123 \
    -e MYSQL_DATABASE=praisonai \
    mysql:8
```

## Quick Start

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
    memory={
        "db": "mysql://root:praison123@localhost:3306/praisonai",
        "session_id": "my-session"
    }
)

response = agent.start("Hello!")
print(response)
```

## Connection String Format

```
mysql://username:password@host:port/database
```

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export PRAISON_CONVERSATION_URL="mysql://root:praison123@localhost:3306/praisonai"
```

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import os
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    memory={"db": os.getenv("PRAISON_CONVERSATION_URL")}
)
```

## CLI

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Validate connection
praisonai persistence doctor \
    --conversation-url "mysql://root:praison123@localhost:3306/praisonai"

# Run with persistence
praisonai persistence run \
    --conversation-url "mysql://root:praison123@localhost:3306/praisonai" \
    --session-id "cli-session" \
    "Hello!"
```

## Troubleshooting

**Connection refused:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Check if MySQL is running
docker ps | grep mysql

# Check logs
docker logs praison-mysql
```
