Install MySQL CLI: mycli with auto-completion
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
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),
$ sudo apt-get install python
$ yum install python
Also, check this tutorial to install Python 3.6 on CentOS/RHEL .
$ dnf install python
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,
$ sudo apt-get update
$ sudo apt-get install mycli
$ sudo dnf install mycli
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,
$ sudo pip install mycli
or we can also use,
$ sudo easy_install mycli
Once installed, we can check the installed version with the following command,
$ mycli -v
& to get the lists of all the commands that can be used with mycli, execute the following command,
$ mycli –help
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,
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.