# mycli — MySQL CLI with Auto-Completion and Syntax Highlighting > mycli is a Python-based interactive CLI for MySQL/MariaDB/Percona with smart auto-completion, syntax highlighting, and result formatting — sister project to pgcli. ## Install Save as a script file and run: # mycli — MySQL CLI with Auto-Completion and Syntax Highlighting ## Quick Use ```bash brew install mycli mycli -h host.example.com -u app -D appdb # Inside mycli > SHOW TABLES; > SELECT * FROM users WHERE -- column completion > G -- vertical output mode > source script.sql ``` ## 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 `G` vertical 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. - `~/.myclirc` stores defaults: pager, vertical threshold, warn-on-destructive. - SSH tunnel: `--ssh-host bastion --ssh-user op`. - Auto-vertical when row width > terminal. - `destructive_warning = true` asks 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. ## Sources - https://github.com/dbcli/mycli - https://www.mycli.net --- Source: https://tokrepo.com/en/workflows/4457836c-38c4-11f1-9bc6-00163e2b0d79 Author: Script Depot