Databases 9 min read

Introducing mycli: A Feature‑Rich MySQL Command‑Line Client

This article introduces mycli, a Python‑based MySQL command‑line client that offers easy installation via pip, advanced auto‑completion, high‑risk operation confirmations, customizable syntax highlighting, output paging, command bookmarking, logging, multiline editing, flexible credential handling, and additional features such as SSL support and query looping.

NetEase Game Operations Platform
NetEase Game Operations Platform
NetEase Game Operations Platform
Introducing mycli: A Feature‑Rich MySQL Command‑Line Client

mycli is a Python‑developed MySQL client that leverages the prompt_toolkit library to provide an interactive command‑line experience with modern features.

Installation : Install via pip with pip install mycli . If installation rights are restricted on a server, coordinate with the SA to define the package in Puppet.

Basic Usage : Connect to a database using $ mycli -u my_user -h my_host.com my_database .

Configuration : The first run creates ~/.myclirc , and mycli also reads the [client] section of MySQL’s configuration files.

Key Features :

Auto‑completion: Provides context‑aware suggestions beyond the basic MySQL client’s --auto-rehash option, allowing selection with the right‑arrow key.

High‑risk operation confirmation: Prompts for a second confirmation on dangerous commands such as drop , shutdown , delete , truncate , and alter , displaying messages like “Wise choice” or “Your call”.

Syntax highlighting: Multiple themes are available; edit the syntax_style entry in ~/.myclirc (e.g., syntax_style = monokai ).

Formatted output: By default, results are piped through less with a sensible LESS="-XFR" configuration.

Command bookmarking: Save frequent SQL statements with \fs alias , list with \f , execute with \f alias , and delete with \fd alias .

Logging: Enable log_file = ~/.mycli.log for general logs and audit_log = ~/.mycli-audit.log for timestamped command audits.

Multiline mode: Activate permanently by setting multi_line = True in ~/.myclirc or temporarily with the F3 key.

Login credentials: Besides the standard .my.cnf and login path, mycli supports DSN aliases defined under [alias_dsn] in ~/.myclirc , e.g., [alias_dsn] testconn = mysql://root:123456@localhost:3306 .

Additional capabilities: SSL connections, pretty‑printed tables, and query looping are also supported.

For a complete reference, consult the official mycli documentation at https://www.mycli.net/ .

Conclusion : mycli offers a more convenient, safer, and feature‑rich alternative to the default MySQL client, making it worthwhile to install and adopt for everyday database work.

SQLMySQLCommand-lineauto completionDatabase Toolsmycli
NetEase Game Operations Platform
Written by

NetEase Game Operations Platform

The NetEase Game Automated Operations Platform delivers stable services for thousands of NetEase titles, focusing on efficient ops workflows, intelligent monitoring, and virtualization.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.