| 1 | # harlequin-mysql |
| 2 | |
| 3 | This repo provides the Harlequin adapter for MySQL/MariaDB. |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | You must install the `harlequin-mysql` package into the same environment as `harlequin`. The best and easiest way to do this is to use `uv` to install Harlequin with the `mysql` extra: |
| 8 | |
| 9 | ```bash |
| 10 | uv tool install 'harlequin[mysql]' |
| 11 | ``` |
| 12 | |
| 13 | ## Usage and Configuration |
| 14 | |
| 15 | You can open Harlequin with the MySQL/MariaDB adapter by selecting it with the `-a` option and passing connection parameters as CLI options: |
| 16 | |
| 17 | ```bash |
| 18 | harlequin -a mysql -h localhost -p 3306 -U root --password example --database dev |
| 19 | ``` |
| 20 | |
| 21 | Note: use `-a mysql` for both MySQL and MariaDB servers. |
| 22 | |
| 23 | The MySQL/MariaDB adapter does not accept a connection string or DSN. |
| 24 | |
| 25 | ### Read-only mode |
| 26 | |
| 27 | This adapter supports Harlequin's `--read-only` option: |
| 28 | |
| 29 | ```bash |
| 30 | harlequin --read-only -a mysql -h localhost -U root --password example --database dev |
| 31 | ``` |
| 32 | |
| 33 | Every connection runs `set session transaction read only`, so the server |
| 34 | refuses DML and DDL with error 1792 (tested on MySQL 8.0 and MariaDB 10.11). |
| 35 | Statements that do not touch data, like `set global ...`, are still allowed; |
| 36 | for a stronger guarantee, connect with a read-only account. |
| 37 | |
| 38 | ### Catalog search |
| 39 | |
| 40 | This adapter supports Harlequin's `--catalog-search` option: |
| 41 | |
| 42 | ```bash |
| 43 | hsql --catalog-search customer_id -a mysql -h localhost -U root --password example |
| 44 | ``` |
| 45 | |
| 46 | The term matches any part of a database, table, view, or column name, |
| 47 | case-insensitively; one query searches every database. |
| 48 | |
| 49 | Many more options are available; to see the full list, run: |
| 50 | |
| 51 | ```bash |
| 52 | harlequin --help |
| 53 | ``` |
| 54 | |
| 55 | For more information, see the [Harlequin Docs](https://harlequin.sh/docs/mysql/index). |