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:
Let us see mycli auto complete feature. Just start typing sql command such as show dat:
Here is a small demo:
See also
- Save time use MySQL/MariaDB auto completion for database or table names with auto-rehash option
- mycli home page
The same goes for PostgreSQL : https://www.pgcli.com/
So exactly the same as the default Mariadb and MySQL CLI?
What is the point?
The default does not offer syntax highlight, db/table selection and much more.