Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand MySQL/MariaDB client MyCLI that supports automatic completion and syntax highlighting

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces how to understand the MySQL/MariaDB client MyCLI that supports automatic completion and syntax highlighting. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

MyCLI is an easy-to-use command line client that can be used on popular database management systems MySQL, MariaDB, and Percona, supporting automatic completion and syntax highlighting. It is written in the prompt_toolkit library and requires the support of Python 2.7,3.3,3.4,3.5,3.6. MyCLI also supports secure connections to MySQL servers through SSL.

Characteristics of MyCLI

When you use it *, a file ~ / .myclirc will be created automatically.

Automatic completion is supported when entering keywords for SQL and tables, views, and columns in the database.

Intelligent completion is also supported by default, and recommendations can be provided based on the relevance of the context.

For example:

SELECT * FROM-this will show the table name in the database. SELECT * FROM users WHERE-this will simply display the column name.

Syntax highlighting is supported by using Pygents

Support for SSL connections

Provide multi-line query support

It records each query and output to a file (disabled by default).

Allows you to save a favorite query (save a query using the\ fs alias and run it with the\ f alias).

Support SQL statement execution and table query timing

Print tabular data in a more attractive way

How to install MyCLI for MySQL and MariaDB on Linux

On the Debian/Ubuntu distribution, you can easily install the MyCLI package using the apt command as follows:

$sudo apt-get update $sudo apt-get install mycli

Similarly, there is a MyCLI package available on Fedora 22 +, which you can install using the dnf command as follows:

$sudo dnf install mycli

For other Linux distributions, such as RHEL/CentOS, you need to use Python's pip tool to install MyCLI. First, install pip using the following command:

$sudo yum install pip

After installing pip, you can install MyCLI as follows:

$sudo pip install mycli

How to use MyCLI to connect MySQL and MariaDB in Linux

Once you have installed MyCLI, you can use it as follows:

$mycli-u root-h localhost

Automatic completion

Simple automatic completion can be done for keywords and SQL functions:

MySQL automatic completion

Intelligent completion

When the FROM keyword is entered, the table name will be completed:

Intelligent completion of MySQL

Alias support

When the alias is set for the table name, the completion of the column name is also supported:

MySQL alias support

Syntax highlighting

MySQL syntax highlighting is supported:

MySQL syntax highlighting

Format the output of SQL

The output of MySQL is formatted by the less command:

MySQL formatted output

To log in to MySQL and select the database at the same time, you can use a command similar to the following:

$mycli local_database $mycli-h localhost-u root app_db $mycli mysql://amjith@localhost:3306/django_poll

For more options, please enter:

Mycli-help on how to understand the automatic completion and syntax highlighting MySQL/MariaDB client MyCLI to share here, I hope the above can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report