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

# Import MySQL

> Import your MySQL database schema into ChartDB

## Download Import Script

Download our MySQL import script:

```bash theme={null}
curl -O https://app.chartdb.io/bash-scripts/mysql-import.sh
chmod +x mysql-import.sh
```

## Usage

Run the script with your database credentials and ChartDB information:

```bash theme={null}
./mysql-import.sh \
  -h your-database-host \
  -P 3306 \
  -u your-database-user \
  -p your-database-password \
  -d your-database-name \
  -a your-chartdb-api-key \
  -t your-diagram-id
```

### Required Parameters

* `-h` Database hostname
* `-P` Database port (default: 3306)
* `-u` Database username
* `-p` Database password
* `-d` Database name
* `-a` ChartDB API key
* `-t` Target diagram ID

The script will connect to your database, extract the schema, and automatically import it into your ChartDB diagram.

## Automated Daily Updates

To automatically update your diagram daily using cron, add the following line to your crontab:

```bash theme={null}
# Run at 2 AM every day
0 2 * * * /path/to/mysql-import.sh -h host -P 3306 -u user -p pass -d dbname -a api_key -t diagram_id >> /path/to/mysql-import.log 2>&1
```

To edit your crontab:

```bash theme={null}
crontab -e
```

<Note>
  **Note:** Replace `/path/to/mysql-import.sh` with the absolute path to the
  script and adjust the credentials accordingly. The log file path
  (`/path/to/mysql-import.log`) should be in a directory where your user has
  write permissions.
</Note>
