Install MySQL CLI: mycli with auto-completion — LinuxTechLab

Shujat Husain
3 min readApr 15, 2019

--

mycli is a command-line tool for MySQL, MariaDB as well as Percona & supports the following features,

- Auto-completion, & Case sensitive completion, as soon we start typing commands this will come into play,
— Syntax highlighting,
— Support for multi-line queries,
— Support for SSL connections,
— Saving of favorite queries,
— Pretty prints tabular data,
— Support for various themes.
— Works well with Unicode input/output.

We can also store every query & its result to a file but this functionality is disabled by default. We can activate this feature by editing the configuration file, which is located at ~/.myclirc. All the log files can be found at ~/.mycli.log.

Recommended Read: Installing & Configuring MariaDB on RHEL/CentOS Also Read: How to install or upgrade PHP version to PHP 7

To install MySQL CLI i.e. mycli, we would need a system that runs python 2.7+ or 3.4+. So make sure that your Linux system has python installed. To install it, run the following command (based on Linux distribution you are using),

Ubuntu

$ sudo apt-get install python

CentOS/RHEL

Also, check this tutorial to install Python 3.6 on CentOS/RHEL .

Fedora

Install MySQL CLI- mycli

For Ubuntu & Fedora, mycli has packages available with the default system package manager repositories & we can use the following commands to install the same of respective systems,

Ubuntu Fedora

This will install MySQL cli i.e. mycli on our systems. But for CentOS & RedHat no rpm packages are available & we need to use pip command to install the same on our system. Using pip, we can install mycli on either Ubuntu, Fedora or CentOS/RHEL.

If you don’t have pip installed on your system, install it using the following tutorial (https://linuxtechlab.com/install-python-pip-python-package-manager/).

Now when we have pip ready, all we need to do is to execute the following command from the terminal,

or we can also use,

$ sudo easy_install mycli

Once installed, we can check the installed version with the following command,

& to get the lists of all the commands that can be used with mycli, execute the following command,

Or you can also first connect to the database using mycli command,

$ mycli -h localhost -u root

& then type ‘help ‘ to get the list of all commands,

mycli> help

This is it for this tutorial on how to install MySQL CLI aka mycli on Linux system. Please feel free to send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these :-

Donate us some of your hard earned money:

Linux TechLab is thankful for your continued support.

Originally published at https://linuxtechlab.com on April 15, 2019.

--

--

Shujat Husain
Shujat Husain

Written by Shujat Husain

A TechEenthusiat who likes all new technologies & Gaming. Most of all love to write about Cloud & DevOPs & have my own blog as well (https://linuxtechlab.com).

No responses yet