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.
What it is
mycli is a Python-based interactive CLI for MySQL, MariaDB, and Percona with smart auto-completion, syntax highlighting, and result formatting. It is the MySQL counterpart of pgcli, part of the dbcli project family.
The tool serves database administrators, backend developers, and data engineers who work with MySQL from the terminal and want a more productive alternative to the default mysql client.
How it saves time or tokens
mycli auto-completes table names, column names, and SQL keywords as you type, eliminating the need to look up schema details manually. Syntax highlighting catches typos visually before you run the query. Formatted output with proper alignment makes result sets readable without copying to a spreadsheet.
How to use
- Install mycli:
pip install mycliorbrew install mycli. - Connect to your database:
mycli -h localhost -u root -p mydb. - Start typing SQL and auto-completion activates automatically.
Example
# Install
pip install mycli
# Connect to a local MySQL database
mycli -h localhost -u root mydb
# Inside mycli, auto-completion works as you type:
# SELECT * FROM or -> suggests: orders, organizations
# SELECT o.id, o.sta -> suggests: status, start_date
# Useful features:
# \T - change output format (table, csv, tsv)
# \f - toggle output to file
# F2 - toggle smart completion mode
# \dt - list tables
Related on TokRepo
- AI Tools for Database -- database management tools and utilities
- Automation Tools -- tools for automating development workflows
Common pitfalls
- mycli's auto-completion loads the schema at connection time. For databases with many tables, this can delay the initial prompt. Use
--no-auto-completefor faster startup on large schemas. - mycli uses less as the default pager. Large result sets page automatically. Set
\Pto change the pager or disable it. - Some MySQL 8.0 features (like CTEs with recursive) work correctly in mycli, but auto-completion may not suggest CTE syntax.
Frequently Asked Questions
mycli adds intelligent auto-completion for tables, columns, and functions, syntax highlighting, multi-line editing, and formatted output. The default mysql client provides none of these features. mycli uses the same connection parameters so it is a drop-in replacement.
Yes. mycli is fully compatible with MariaDB and Percona Server. It uses the PyMySQL library which supports all MySQL-protocol-compatible databases.
Yes. mycli connects to Amazon RDS, Google Cloud SQL, Azure Database for MySQL, PlanetScale, and any other MySQL-compatible cloud service using standard connection parameters.
Yes. Both are part of the dbcli project. pgcli is for PostgreSQL, mycli is for MySQL. They share the same design philosophy and similar user experience.
Yes. mycli supports SSL via the --ssl-ca, --ssl-cert, and --ssl-key flags. It passes SSL parameters through to the underlying PyMySQL connection.
Citations (3)
- mycli GitHub— Python-based MySQL CLI with auto-completion
- dbcli Project— Part of the dbcli project family
- mycli Official Site— Smart completion for MySQL syntax and schema
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.