How to Install MyCli on Ubuntu 20.04

Install MyCli on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure MyCli on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

CLI is a command-line interface for MySQL, MariaDB, and Percona with auto-completion and syntax highlighting. The auto-completion will help you write queries faster and with ease. The REPL (Read, Eval, Print, Loop) will pop up a suggestion menu as soon as you start typing. The suggestions are context based on the position of the cursor.

MyCLI Features

  • Auto-completion as you type for SQL keywords as well as tables, views, and columns in the database.
  • Syntax highlighting of input while typing.
  • Support for multiline queries.
  • Allows you to save your favorite queries.
  • Prints tabular data in an appealing way.
  • Support for SSL connections.
  • Smart-completion (enabled by default) will suggest context-sensitive completion.
  • Log every query and its results to a file.

Install MyCli on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install MyCli on the Ubuntu system.

  • Installing MyCli from the official repository

Now install the MyCLI package using the following command below:

sudo apt install mycli
  • Installing MyCli via Snap

Run the following command below to install snap and MyCli:

sudo apt install snapd
sudo snap install mycli

Step 3. Using MyCli on Ubuntu.

Using MyCli is very easy because it is not intended to be a replacement for the MySQL shell but to provide more and better features. So, to deploy the command help, just open your terminal and run:

# mycli  --help
Usage: mycli [OPTIONS] [DATABASE]

  -h, --host TEXT               Host address of the database.
  -P, --port INTEGER            Port number to use for connection. Honors
  -u, --user TEXT               User name to connect to the database.
  -S, --socket TEXT             The socket file to use for connection.
  -p, --password TEXT           Password to connect to the database
  --pass TEXT                   Password to connect to the database
  --ssl-ca PATH                 CA file in PEM format
  --ssl-capath TEXT             CA directory
  --ssl-cert PATH               X509 cert in PEM format
  --ssl-key PATH                X509 key in PEM format
  --ssl-cipher TEXT             SSL cipher to use
  --ssl-verify-server-cert      Verify server's "Common Name" in its cert
                                against hostname used when connecting. This
                                option is disabled by default
  -v, --version                 Version of mycli.
  -D, --database TEXT           Database to use.
  -R, --prompt TEXT             Prompt format (Default: "\t \[email protected]\h:\d> ")
  -l, --logfile FILENAME        Log every query and its results to a file.
  --defaults-group-suffix TEXT  Read config group with the specified suffix.
  --defaults-file PATH          Only read default options from the given file
  --auto-vertical-output        Automatically switch to vertical output mode
                                if the result is wider than the terminal
  -t, --table                   Display batch output in table format.
  --warn / --no-warn            Warn before running a destructive query.
  --local-infile BOOLEAN        Enable/disable LOAD DATA LOCAL INFILE.
  --login-path TEXT             Read this path from the login file.
  -e, --execute TEXT            Execute query to the database.
  --help                        Show this message and exit.

That’s all you need to do to install the MyCli on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on MyCli, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.