Mycli – Simple CLI Client For MySQL/MariaDB With AutoCompletion And Syntax Highlighting

MyCLI is a command line interface for MySQL, MariaDB, and Percona with auto-completion and syntax highlighting. This will help us to write queries faster and easy which was written in Python prompt_toolkit.

The REPL (Read, Eval, Print, Loop) will pop up a suggestion menu as soon as you start typing. The suggestions are context sensitive based on the position of the cursor.

Frequently used queries can be saved as favorite queries with a short name, which can be retrieved whenever we want by invoking /f .

MyCli keeps track of the queries entered in the repl. Up/Down arrow can be used to navigate the history. Mycli uses pager programs to make it easier to view largeresult sets. This can be configured or disabled.

Mycli Features :

  • Auto-completion as you type for SQL keywords as well as tables, views and columns in the database.
  • Syntax highlighting using Pygments.
  • Smart-completion (enabled by default) will suggest context-sensitive completion.
  • SELECT * FROM will only show table names.
  • SELECT * FROM users WHERE will only show column names.
  • Support for multiline queries.
  • Favorite queries. Save a query using \fs alias query and execute it with \f alias whenever you need.
  • Timing of sql statments and table rendering.
  • Config file is automatically created at ~/.myclirc at first launch.
  • Log every query and its results to a file (disabled by default).
  • Pretty prints tabular data (with colors!)
  • Support for SSL connections

MyCLI is very useful since lot’s of small companies & CMS (Content Management System) application such as WordPress, Joomla, Moodle, etc,., using MysQL/MariaDB as aback end.

MyCLI config file is located @ ~/.myclirc and you have plenty of options for customization. The config file is created when mycli is launched for the very first time. Default log file is located at ~/.mycli.log.

How to install Mycli on Linux

Make sure your system should have python-pip package in order to install Mycli. pip is a python module bundled with setuptools, it’s one of the recommended tool for installing Python packages in Linux.

For Debian/Ubuntu, use apt-get command or apt command to install Mycli.

$ sudo apt install python-pip

Alternatively we can install from distribution official repository but you might get bit older version.

$ sudo apt-get install mycli

For RHEL/CentOS, use YUM command to install Mycli.

$ sudo yum install python-pip python-devel

For Fedora, use dnf command to install Mycli.

$ sudo dnf install python-pip

Mycli package was included in Fedora system since Fedora 22, so you can easily install from distribution official repository but you might get bit older version.

$ sudo dnf install mycli

For Arch Linux, use pacman command to install Mycli.

$ sudo pacman -S python-pip

Finally Install Mycli using pip command

$ pip install mycli

How to use Mycli

Just run the following command to invoke mycli interface and start enjoying with AutoCompletion And Syntax Highlighting

$ mycli -u user -p db_name
$ mycli -u root -p

Auto-completion : Simple completions such as keywords and sql-functions.

Smart-completion : Table name completions after the ‘FROM’ keyword.

Column names are scoped to the table referenced in the query.

Alias support : Column completions will work even when table names are aliased.

You may also like...

Shares
Close
Please support the site
By clicking any of these buttons you help our site to get better