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

> ## Agent Instructions
> These are the docs for Sevalla, a platform for deploying applications, databases, static sites, object storage and load balancers. The dashboard is at https://app.sevalla.com.
> Bold text in steps is an exact dashboard label.
> To act on a Sevalla account, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md), then the Sevalla CLI (https://docs.sevalla.com/developer-tools/cli.md), then the REST API (https://api-docs.sevalla.com, OpenAPI spec at https://api.sevalla.com/v3/openapi.json).
> Every page index is at https://docs.sevalla.com/llms.txt.

# Import and export MySQL

> Export a Sevalla MySQL database with mysqldump and import a SQL dump with the mysql client over the external connection, including dumps from other providers.

You move data into and out of a Sevalla MySQL database with MySQL's own tools over the database's [external connection](https://docs.sevalla.com/databases/connect.md#enable-the-external-connection): `mysqldump` to export, the `mysql` client to import. The same commands move a database from another provider to Sevalla.

## Before you begin

* Create the database on Sevalla first, on the same MySQL version as the source or a newer one. See [Create a database](https://docs.sevalla.com/databases/create.md).
* [Enable the external connection](https://docs.sevalla.com/databases/connect.md#enable-the-external-connection). If [IP restrictions](https://docs.sevalla.com/databases/connect.md#restrict-access-by-ip-address) are on, allow your IP address.
* Install MySQL's client tools (`mysqldump` and `mysql`), version 8.0 or later. Use MySQL's tools, not MariaDB's. Get them from [dev.mysql.com/downloads](https://dev.mysql.com/downloads/): on macOS `brew install mysql-client`, on Debian or Ubuntu the `mysql-client` package from the MySQL APT repository, on Windows the MySQL installer.
* Copy the **Host**, **Port**, **Database**, **User** and **Password** from the database's **Overview** tab, under **Connection** > **External**. See [Find the connection details](https://docs.sevalla.com/databases/connect.md#find-the-connection-details).

The examples use the host `orders-db-k3j4h.ext.sevalla.app`, port `20145`, database `orders` and user `orders`; replace them with yours. `--password` makes each command ask for the password.

## Export a database

```bash theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
mysqldump --host=orders-db-k3j4h.ext.sevalla.app --port=20145 \
  --user=orders --password \
  --single-transaction --set-gtid-purged=OFF --no-tablespaces \
  --routines --triggers --events --hex-blob \
  orders > orders.sql
```

| Option | Why |
| - | - |
| `--single-transaction` | A consistent dump without locking tables |
| `--set-gtid-purged=OFF` | Leaves out GTID statements, which need privileges the database user doesn't have when you import |
| `--no-tablespaces` | Skips tablespace information, which needs the `PROCESS` privilege |
| `--routines --triggers --events` | Includes stored procedures, functions, triggers and events |
| `--hex-blob` | Writes binary columns as hexadecimal so they survive the round trip |

To export from another provider before you move to Sevalla, run the same command with that provider's host, port, user and database.

## Import a database

```bash theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
mysql --host=orders-db-k3j4h.ext.sevalla.app --port=20145 \
  --user=orders --password \
  orders < orders.sql
```

The command prints nothing unless there's an error. Import into an empty database: a dump made by `mysqldump` drops and recreates each table it contains. Check the result by listing the tables:

```bash theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
mysql --host=orders-db-k3j4h.ext.sevalla.app --port=20145 --user=orders --password orders --execute='SHOW TABLES;'
```

## Restore a dump backup

Databases in OCI locations write their [dump backups](https://docs.sevalla.com/databases/backups.md#external-backups-on-oci) as gzip-compressed SQL made with the options in [Export a database](#export-a-database). [Download one](https://docs.sevalla.com/databases/backups.md#download-a-dump-backup) and load it into any MySQL database of the same or a newer version:

```bash theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
gunzip -c 20261018-000000_automatic_mysql8.0_orders-db-backups.sql.gz | \
  mysql --host=orders-db-k3j4h.ext.sevalla.app --port=20145 --user=orders --password orders
```

To restore a Sevalla backup into a Sevalla database, use **Restore** on the **Backups** tab instead. See [Restore a backup](https://docs.sevalla.com/databases/backups.md#restore-a-backup).

## Common errors

| Error | Fix |
| - | - |
| `Access denied; you need (at least one of) the SUPER, SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN privilege(s) for this operation` | The dump sets GTID or other global variables. Export again with `--set-gtid-purged=OFF`. |
| `Access denied; you need (at least one of) the PROCESS privilege(s) for this operation` while dumping | Add `--no-tablespaces`. |
| `Access denied; you need (at least one of) the SUPER or SET_USER_ID privilege(s) for this operation` | A view, trigger or routine names another user as `DEFINER`. Remove the `DEFINER=...` clauses from the dump, or recreate those objects as the database user. |
| `Can't connect to MySQL server` or `Lost connection to MySQL server` | Check the external connection is on and the host and port match the dashboard. See [Troubleshoot databases](https://docs.sevalla.com/databases/troubleshooting.md). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.