Search Shortcut cmd + k | ctrl + k
Search cmd+k ctrl+k
0.10 (stable)
MySQL Import

To run a query directly on a running MySQL database, the mysql extension is required.

Installation and Loading

The extension can be installed use the INSTALL SQL command. This only needs to be run once.

INSTALL mysql;

To load the mysql extension for usage, use the LOAD SQL command:

LOAD mysql;


After the mysql extension is installed, you can attach to a MySQL database using the following command:

ATTACH 'host=localhost user=root port=0 database=mysqlscanner' AS mysql_db (TYPE mysql_scanner, READ_ONLY);
USE mysql_db;

The string used by ATTACH is a PostgreSQL-style connection string (not a MySQL connection string!). It is a list of connection arguments provided in {key}={value} format. Below is a list of valid arguments. Any options not provided are replaced by their default values.

Setting Default
database NULL
host localhost
port 0
socket NULL
user current user

You can directly read and write the MySQL database:

INSERT INTO tbl VALUES (42, 'DuckDB');

For a list of supported operations, see the MySQL extension documentation.

About this page

Last modified: 2024-05-22