Mycli, a MySQL client for the terminal with autocompletion

about mycli

In the next article we are going to take a look at mycli. Next we will see the installation in Ubuntu of this MySQL client for terminal. It is written in Python using the library Python Prompt Toolkit and in the se includes autocompletion and syntax highlighting. It will work with MySQL, MariaDB and Percona database servers.

This client will be especially useful when it comes to write complex queries easily and quickly without having to remember the entire query syntax. It is going to give users the possibility to use the REPL (Read, Evaluate, Print, Loop) that will appear in the suggestions menu as soon as we start typing.

General features of mycli

mycli autocomplete

Mycli is a command line tool for MySQL, MariaDB and Percona and supports the following functions:

  • Let's meet the autocomplete and complete upper or lower case. As soon as we start typing commands, this will come into play.
  • Auto-populate while typing SQL keywords, as well as tables, views, and columns in the database.
  • Nice prints of tabular data in which you can see the colors. As we write our queries, we will see that the reserved words will have one color, while the data and constants another. This will allow users to quickly and easily identify and analyze the queries we make to the DB.
  • This client is going to offer us support for multi-line queries.
  • Support for SSL / TLS connections.
  • We will have the possibility of save our queries favorites. We will also be able to store your result in a file. This functionality is disabled by default but we can activate it by editing the configuration file, found in ~ / .myclirc.
  • All records we will be able to find them in the file ~ / .mycli.log.
  • We will find support to be able to use various themes.
  • Works well with Unicode input / output.

These are just some of its features. We will be able to find all its features on his GitHub page.

Install mycli on Ubuntu

Python 3.6 shell
Related article:
Python 3.6, install it from PPA or compile its source code on Ubuntu

To install MySQL CLI, i.e. mycli, we would need a system running python 2.7+ or 3.4+. For this reason we will have to make sure that our Ubuntu system has Python installed. If we do not have this language, to install it, execute the following command in a terminal (Ctrl + Alt + T):

sudo apt install python

Once the above requirement is fulfilled, mycli has packages available in package manager repositories of the system. We will be able to use the following script to install this client:

install mycli from apt

sudo apt update && sudo apt install mycli

Another installation option will be to use pip. To install mycli using this Python package manager, you just have to type in the terminal (Ctrl + Alt + T):

sudo pip3 install mycli

After the installation, we will be able check the version of the installed client with the following command:

view mycli version

mycli -v

To begin with, we will be able to connect using the command as shown below:

mycli running

sudo mycli

Note that the suggestions are context sensitive depending on the position of the cursor. For example: only tables are suggested after the FROM keyword and only column names are suggested after the WHERE clause.

Help

To get the list of all commands that can be used with mycliAll you have to do is run the following help command in the terminal:

mycli help

mycli --help

For learn more about using mycli, users can consult the official documentation offered on the project website.

In summary, mycli is a good client-side tool that will shorten the time of writing queries in the terminal since it will suggest table and column names as we write a query. If anyone is interested, it must be said that there is also an equivalent tool for postgres with the name pgcli which has been developed by Amjith.


Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.