Export or migrate a MySQL database
The Export / Migrate tab copies databases or tables from one open MySQL/MariaDB connection to an SQL file, the clipboard (up to 16 MiB) or another connection. The source is only read. Every option and statement in detail: Export and migration.
1. Open both connections
Section titled “1. Open both connections”Open the source session and, for a migration, the target session. The target must be a saved session with Allow write (write mode in tabs, migration target) checked (Sessions → Edit → Database settings); a quick connect tab cannot be a target. Production on the target adds a second confirmation. A target behind ProxySQL is refused: use a session with The MySQL / MariaDB server itself.
2. Pick what to copy
Section titled “2. Pick what to copy”In the Databases window, right-click a database or a table → Export… (file) or Migrate… (connection). In the tab, check more databases or tables in the source tree. A checked database copies everything in it, including routines and triggers when those options are on; picked tables copy only those tables, their views and triggers.
With one source database, Database under the target renames it (for example shop →
shop_copy); view definitions are rewritten to the new name.
3. Options
Section titled “3. Options”| Option | Default | What it does |
|---|---|---|
| DROP DATABASE | off | DROP DATABASE IF EXISTS on the target first (also removes what is not copied). |
| CREATE DATABASE | on | CREATE DATABASE IF NOT EXISTS with the source’s character set and collation; needed when the target database does not exist. |
| DROP TABLE / VIEW | on | DROP … IF EXISTS before each table, view, routine and trigger. |
| CREATE TABLE / VIEW | on | SHOW CREATE of the source, sent as is. |
| Data | INSERT | INSERT, REPLACE, INSERT IGNORE or none (structure only). |
| Max INSERT size | 1048576 bytes | Longest statement; kept below the target’s max_allowed_packet. |
| Rows per INSERT | 1000 | Rows in one statement. |
| Rows per SELECT | 5000 | Rows read per chunk, ordered by the primary key. |
| Views, Procedures and functions, Triggers | views on | Copied after the tables; views in dependency order, triggers last so they do not fire on the copied rows. |
| Keep DEFINER | off | Without it, DEFINER=… is removed, so the objects belong to the target account. Keeping it needs SET_USER_ID or SUPER on the target. |
4. Prepare and start
Section titled “4. Prepare and start”Prepare plan reads the catalogs and shows every step, a summary of the statements and the first DDL statements in full. For a connection target, Start shows the plan again and asks for confirmation (and a second one for production). An SQL file is chosen in the save panel.
What the run does:
- Source: a separate read-only connection with the tab’s login and TLS,
time_zone '+00:00', an emptysql_modeand oneSTART TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY, so all tables are read as of one moment. Tables with a primary key of integer, decimal, date/time, CHAR/VARCHAR or BINARY/VARBINARY columns are read in chunks (WHERE pk > last ORDER BY pk LIMIT n); other tables in a single streamedSELECT. Behind ProxySQL there is no snapshot (each statement may go to another backend), which the plan says. - Target: a separate connection with
SET NAMES utf8mb4,time_zone '+00:00',sql_mode = 'NO_AUTO_VALUE_ON_ZERO'(as mysqldump),FOREIGN_KEY_CHECKS=0,UNIQUE_CHECKS=0and autocommit; each value is read back before the first write. Target warnings (truncated values, skipped duplicates) appear in the log. Procedures and triggers are created with their ownsql_mode. The run refuses a target that is the same server and database as the source. Every statement commits on its own: a stop leaves the finished steps on the target. - Values are written exactly: numbers as the server printed them (FLOAT read as DOUBLE), binary,
BITand spatial columns as0x…, text quoted. Generated columns are left to the server. SHOW CREATEof a table or view must be one statement creating that object, otherwise it is not sent. Procedure and trigger bodies are sent as they are.
The tab shows rows, bytes and time per step and the server’s error with its code and SQLSTATE.
Both connection consoles log the statements ([export], [migration]; INSERTs as a summary).
Cancel stops the current statement (KILL QUERY over the tab’s connection). After a failure
of a migration, Resume from step N (or from here on any step) runs the plan again from
that step in a new snapshot; a file or the clipboard always starts at the first step; with DROP TABLE off, choose REPLACE
or INSERT IGNORE to avoid duplicates. After a migration, COUNT(*) runs on both sides for every
copied table; differences are marked. Copy log copies the log and the step table.
Only MySQL/MariaDB to MySQL/MariaDB; events are not copied.