# MySQL

Bobby Tables connects to MySQL servers and opens each connection in a SQL workspace with a catalog sidebar, table grids, a structure editor and a SQL editor.

## Where to find it

| Action | How |
| --- | --- |
| Choose MySQL | `New connection`, `⌘N` (`Ctrl+N`), then `MySQL` under `Choose a provider` |
| Fill the form from a URL | `Use connection URL` with a `mysql://` URL, then `Fill fields` |
| Default port | `3306` |
A `mysql://` URL with port `4000` or a TiDB Cloud host fills the form as [TiDB](https://bobbytables.app/docs/tidb). MariaDB has its own provider, described on the [MariaDB](https://bobbytables.app/docs/mariadb) page.

## Connecting

The form asks for `Host`, `Port`, `User`, `Database (optional)` and `Password`, and notes that the connection `Uses 2 server connections`. The second connection is kept for cancelling queries. `Test connection` reads the server version and refuses a TiDB server selected as MySQL, and [SSH and TLS](https://bobbytables.app/docs/ssh-and-tls) covers the `TLS` and `SSH tunnel` sections. `Open in read-only mode` sets a read-only session transaction and disables editing.

## What works

- Browse databases, tables, views, routines and triggers in the [table grid](https://bobbytables.app/docs/table-data).
- Stage inserts, updates and deletes, then commit them in one transaction, as described in [Editing](https://bobbytables.app/docs/editing).
- Change columns, indexes and keys in the [Structure](https://bobbytables.app/docs/structure) tab, one DDL statement at a time.
- Take a consistent [snapshot](https://bobbytables.app/docs/snapshots) with the built-in engine or an installed `mysqldump`, without locking tables.
- Draw a [schema diagram](https://bobbytables.app/docs/schema-diagram) from declared foreign keys.
- Format result columns with [result directives](https://bobbytables.app/docs/result-directives).
- Stop a running statement with `Cancel`, `⌘.` (`Ctrl+.`), which sends `KILL QUERY`.
- Run `Explain`, `⌘⇧E` (`Ctrl+Shift+E`), or `Explain Analyze`, `⌘⇧⌥E` (`Ctrl+Shift+Alt+E`), in the [SQL editor](https://bobbytables.app/docs/sql-editor).

## Engine notes

MySQL cannot roll back DDL, so committing a structure change opens `SQL preview` with the warning `MySQL cannot roll back DDL. Statements run one by one; a failure leaves earlier statements applied.` Accounts that use `caching_sha2_password` connect without extra settings. Values are read through the text protocol, so a column of any type renders without a type-specific decoder.

## Good to know

- Only transactional tables are point-in-time consistent in a snapshot, and the preflight names every non-InnoDB table in scope.
- A table with no primary key stays read-only, with a banner saying why.

## Related

- [MariaDB](https://bobbytables.app/docs/mariadb.md)
- [TiDB](https://bobbytables.app/docs/tidb.md)
- [Structure](https://bobbytables.app/docs/structure.md)
- [Engines, file sources and platforms](https://bobbytables.app/docs/engines.md)
