Introduction
mysql CLI works, but its readline bindings feel primitive next to a modern IDE console. mycli closes the gap: aware of table and column names, colored SQL, parameter placeholders, and friendly result formatting. Connects to MySQL, MariaDB, Percona, TiDB, CockroachDB (via MySQL protocol), PlanetScale.
What mycli Does
- Interactive REPL for MySQL-compatible databases.
- Context-aware completion from live schema.
- Syntax-highlighted input.
- Pretty tables with
Gvertical toggle. - Named queries, favorites, connection profiles.
Architecture Overview
mycli uses PyMySQL for connectivity and prompt-toolkit for the REPL. Schema introspection populates completion tries. Syntax highlighting via Pygments. Output formatting via cli-helpers. Configuration mirrors pgcli's ~/.myclirc.
Self-Hosting & Configuration
- Install via pip, brew, apt, dnf.
~/.myclircstores defaults: pager, vertical threshold, warn-on-destructive.- SSH tunnel:
--ssh-host bastion --ssh-user op. - Auto-vertical when row width > terminal.
destructive_warning = trueasks before DELETE/UPDATE without WHERE.
Key Features
- Smart completion with JOIN help.
- Pager integration.
- Multiline editor (vi/emacs keybindings).
- Connection multiplexer — switch DBs with
. - Safer than stock client with destructive-warning flag.
Comparison with Similar Tools
- mysql — stock client; universal, basic.
- pgcli — same pattern for PostgreSQL.
- mysqlsh — official Python/JS shell; heavier.
- dbeaver — GUI.
- usql — multi-DB CLI.
FAQ
Q: Works with TiDB/MariaDB? A: Yes — MySQL protocol-compatible.
Q: Safer deletes?
A: destructive_warning = true prompts when WHERE is missing.
Q: Export CSV?
A: T csv then run query.
Q: Password auth?
A: Set MYSQL_PWD or use --login-path for mysql_config_editor files.