ScriptsApr 15, 2026·2 min read

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.

TL;DR
mycli replaces the default mysql client with auto-completion, syntax highlighting, and formatting.
§01

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.

§02

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.

§03

How to use

  1. Install mycli: pip install mycli or brew install mycli.
  2. Connect to your database: mycli -h localhost -u root -p mydb.
  3. Start typing SQL and auto-completion activates automatically.
§04

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
§05

Related on TokRepo

§06

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-complete for faster startup on large schemas.
  • mycli uses less as the default pager. Large result sets page automatically. Set \P to 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

How does mycli differ from the default mysql client?+

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.

Does mycli support MariaDB?+

Yes. mycli is fully compatible with MariaDB and Percona Server. It uses the PyMySQL library which supports all MySQL-protocol-compatible databases.

Can mycli connect to cloud MySQL services?+

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.

Is mycli related to pgcli?+

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.

Does mycli support SSL connections?+

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)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets