If we are using MySQL or MariaDB it is because we know the commands and the sentences. However, many times, despite knowing them, we can make a mistake. And a mistake could result in a loss of time or great damage to our database. For this and other reasons is that usually, on the client side we use applications to help us with the task. And on the server side? Fortunately, on the server side, we have available a tool that will help us interact with MySQL or MariaDB. So today I will teach you how to install MyCLI to improve the SQL typing.
MyCLI is a tool made in Python with a BSD license that will help us to interact with the SQL language. It supports syntax highlighting and autocompletion. Currently, it only supports MySQL and MariaDB, more than enough for daily work. It has versions for Linux, Windows, and MacOS but it is in Linux where it is more focused.
So, let us install it.
Install MyCLI on Linux
MyCLI is easy to install on our Linux distribution because it is available through PIP. However, for some systems, it is found in the official repositories making installation even easier. So let us go for it.
If you are using Debian, Ubuntu, Linux Mint or ElementaryOS, open a terminal and run:
:~$ sudo apt install mycli
On the other hand, if you are using Fedora:
:~$ sudo dnf install mycli
However for others Linux distribution, you have to install python PIP and then,
:~$ pip install mycli
As you can see the installation is simple.
Basic use of MyCLI
Once we have it installed in our system, it only remains to start using it.
To use it, it is necessary to follow this syntax:
:~$ mycli -u [user] -p [database]
Then, you will have to type the root password to enter. It is also possible to do this by specifying a user and a host, for example:
:~$ mycli -u [user] -h [host] -p [database]
Once you have entered your password, you will see that you can start working. Its main feature is the autocompletion of the syntax.
Finally, MyCLI has the help that you can take full advantage of.
:~$ mycli --help
This way you will be able to use MyCLI better.
MyCLI is a very simple tool but it will help a lot in SQL management. Although it is limited to MySQL and MariaDB it is enough for our daily work or educational project. This greatly improves workflow and agility in SQL.