nixCraft

mycli: Awesome MySQL/MariaDB mysql client with auto-completion and syntax highlighting

I already wrote about auto-completion in the MySQL/MaiaDB command-line client using an auto-rehash feature. Recently I found out a new tool called mycli. It is a command line interface for MySQL, MariaDB, and Percona with auto-completion and syntax highlighting.

This tool is written in Python. You need to use pip command to install it on Linux or Unix-like system. This tool support auto-completion table names, database names, aliases, SQL syntax, keeps track of the queries entered, and much more.

Installation

If pip not installed on a Debian/Ubuntu Linux, type the following apt command/apt-get command:
$ sudo apt install python-pip
If you are using RHEL/CentOS, use yum command to install the same:
$ sudo yum install python-pip

Install mycli

Type the following command on Linux or Unix-like system to install mycli:
$ pip install mycli
If you are using macOS Unix, type the following brew command to install mycli:
$ brew update && brew install mycli
Sample outputs:

==> Downloading https://homebrew.bintray.com/bottles/mycli-1.10.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mycli-1.10.0.sierra.bottle.tar.gz
==> Using the sandbox
🍺  /usr/local/Cellar/mycli/1.10.0: 1,293 files, 24.4MB

How do I use mycli command?

The syntax is:
$ mycli -u user -p db_name
$ mycli -u user -h host_name -p db_name

Sample outputs:

Fig.01: mycli in action

Let us see mycli auto complete feature. Just start typing sql command such as show dat:
Fig.02: Simple completions such as keywords and sql-functions.

Here is a small demo:
Gif.01: Auto-completion and syntax demo

See also