# mycli

> MySQL command line client with auto-completion, syntax highlighting, and smart context-aware SQL suggestions

Stars: 12.0k · Language: Python · License: BSD-3-Clause · Categories: Data

- Repository: https://github.com/dbcli/mycli
- Website: http://mycli.net
- Page: https://www.trmn.sh/tools/mycli

## Install

- pip: `pip install -U 'mycli[all]'`
- Homebrew: `brew update && brew install mycli`
- apt: `sudo apt-get install mycli`

## Overview

mycli is a MySQL command line client that enhances the standard mysql CLI with interactive features. Built on Python Prompt Toolkit, it provides auto-completion for SQL keywords, table names, views, and columns as the user types. The tool includes context-aware smart completion that suggests only relevant options based on query context - for example, showing only table names after SELECT * FROM and only column names in WHERE clauses.

The client supports fuzzy history search using fzf, syntax highlighting via Pygments, and multiline queries. Users can save favorite queries with positional parameters using \fs commands and execute them with \f aliases. Additional features include query timing, result logging to files, SSL connection support, and shell-style output redirection with $>, $>>, and $| operators.

mycli targets database administrators, developers, and anyone working regularly with MySQL databases who wants a more interactive command line experience. It creates a ~/.myclirc configuration file on first run for customizing behavior and key bindings. The tool requires Python 3.10+ and runs on macOS and Linux, with experimental Windows support through WSL or native installation.

### Installation

```bash
# via pip
pip install -U 'mycli[all]'
```

```bash
# via Homebrew
brew update && brew install mycli
```

```bash
# via apt
sudo apt-get install mycli
```

![Auto-completion interface](https://media.trmn.sh/cached/05edfd72b618eb0df81e715e47343ab46456319124b8c0f8122a9b6553d37378.png)

![Interactive completion demo](https://media.trmn.sh/cached/0458bea5510ffc67d24bdc92ee12ccac011941ef8f996492d452db029579cc8c.gif)

## Alternatives

- [pgcli](https://www.trmn.sh/tools/pgcli.md): Interactive PostgreSQL client with auto-completion, syntax highlighting, and smart context-sensitive suggestions. (Python, 13.4k stars)
- [visidata](https://www.trmn.sh/tools/visidata.md): Terminal interface for exploring and arranging tabular data with support for CSV, JSON, SQLite, Excel, and many other formats. (Python, 9.4k stars)
- [jc](https://www.trmn.sh/tools/jc.md): Converts output of CLI tools, file types, and strings to JSON or Python dictionaries so it can be piped to jq and used in scripts. (Python, 8.7k stars)
- [litecli](https://www.trmn.sh/tools/litecli.md): Command-line client for SQLite databases with auto-completion and syntax highlighting. (Python, 3.3k stars)
- [dolphie](https://www.trmn.sh/tools/dolphie.md): Real-time terminal interface for monitoring MySQL/MariaDB and ProxySQL database performance and analytics (Python, 1.2k stars)

## Guides

- [Best Database CLI Clients](https://www.trmn.sh/best/database-clients): Compare usql, pgcli, mycli, harlequin and lazysql for querying Postgres, MySQL and SQLite from the terminal, with notes on dblab.

---

Canonical: https://www.trmn.sh/tools/mycli
