分享一個MySQL命令列自動完成和補全的小工具
MySQL的命令列客戶端工具mycli,可以實現命令列自動完成補全和語法突出顯示。
主頁:
文件: /docs
安裝方法:
# pip install -U mycli
Collecting mycli
Downloading (56kB)
100% |████████████████████████████████| 61kB 27kB/s
Collecting PyMySQL>=0.9.2 (from mycli)
Downloading (47kB)
100% |████████████████████████████████| 51kB 11kB/s
Collecting sqlparse<0.3.0,>=0.2.2 (from mycli)
Downloading
Collecting configobj>=5.0.5 (from mycli)
Downloading
Collecting cryptography>=1.0.0 (from mycli)
Downloading (2.3MB)
100% |████████████████████████████████| 2.3MB 1.3MB/s
Collecting cli-helpers[styles]>=1.0.1 (from mycli)
Downloading
Collecting Pygments>=1.6 (from mycli)
Downloading (883kB)
100% |████████████████████████████████| 890kB 1.5MB/s
Collecting prompt-toolkit>=2.0.6 (from mycli)
Downloading (337kB)
100% |████████████████████████████████| 337kB 1.5MB/s
Collecting click>=4.1 (from mycli)
Using cached
Collecting six (from configobj>=5.0.5->mycli)
Downloading
Collecting cffi!=1.11.3,>=1.8 (from cryptography>=1.0.0->mycli)
Downloading (430kB)
100% |████████████████████████████████| 440kB 1.5MB/s
Collecting asn1crypto>=0.21.0 (from cryptography>=1.0.0->mycli)
Using cached
Collecting tabulate[widechars]>=0.8.2 (from cli-helpers[styles]>=1.0.1->mycli)
Downloading (46kB)
100% |████████████████████████████████| 51kB 5.7MB/s
Collecting terminaltables>=3.0.0 (from cli-helpers[styles]>=1.0.1->mycli)
Downloading
Collecting wcwidth (from prompt-toolkit>=2.0.6->mycli)
Downloading
Collecting pycparser (from cffi!=1.11.3,>=1.8->cryptography>=1.0.0->mycli)
Using cached
Installing collected packages: PyMySQL, sqlparse, six, configobj, pycparser, cffi, asn1crypto, cryptography, wcwidth, tabulate, terminaltables, Pygments, cli-helpers, prompt-toolkit, click, mycli
Running setup.py install for configobj ... done
Running setup.py install for pycparser ... done
Running setup.py install for tabulate ... done
Running setup.py install for terminaltables ... done
Successfully installed PyMySQL-0.9.3 Pygments-2.4.2 asn1crypto-0.24.0 cffi-1.12.3 cli-helpers-1.2.1 click-7.0 configobj-5.0.6 cryptography-2.7 mycli-1.19.0 prompt-toolkit-2.0.9 pycparser-2.19 six-1.12.0 sqlparse-0.2.4 tabulate-0.8.3 terminaltables-3.1.0 wcwidth-0.1.7
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@test1 20190626]#
使用舉例:
Examples:
- mycli my_database
- mycli -u my_user -h my_host.com my_database
- mycli mysql://my_user@my_host.com:3306/my_database
# mycli -uroot -p -D test -h 192.168.16.150
Password:
mysql 5.7.24-log
mycli 1.19.0
Chat:
Mail: !forum/mycli-users
Home:
Thanks to the contributor - Dick Marinus
mysql root@192.168.16.150:test> select * from
aaa
dsf
dsf_old
peihy
sq_prebycollecttime
t
t1
mysql> select * from dsf order by rand() limit 5 \G
***************************[ 1. row ]***************************
id | 281730
name | <null>
***************************[ 2. row ]***************************
id | 448833
name | <null>
***************************[ 3. row ]***************************
id | 441833
name | <null>
***************************[ 4. row ]***************************
id | 686905
name | <null>
***************************[ 5. row ]***************************
id | 392884
name | <null>
5 rows in set
Time: 1.311s
mysql>
說明:
mycli命令後面必須用-D跟資料庫名,否則會報錯:
(1049, "Unknown database
命令幫助資訊:
# mycli --help
Usage: mycli [OPTIONS] [DATABASE]
A MySQL terminal client with auto-completion and syntax highlighting.
Examples:
- mycli my_database
- mycli -u my_user -h my_host.com my_database
- mycli mysql://my_user@my_host.com:3306/my_database
Options:
-h, --host TEXT Host address of the database.
-P, --port INTEGER Port number to use for connection. Honors
$MYSQL_TCP_PORT.
-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.
--ssh-user TEXT User name to connect to ssh server.
--ssh-host TEXT Host name to connect to ssh server.
--ssh-port INTEGER Port to connect to ssh server.
--ssh-password TEXT Password to connect to ssh server.
--ssh-key-filename TEXT Private key filename (identify file) for the
ssh connection.
--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 Output mycli's version.
-v, --verbose Verbose output.
-D, --database TEXT Database to use.
-d, --dsn TEXT Use DSN configured into the [alias_dsn]
section of myclirc file.
--list-dsn list of DSN configured into the [alias_dsn]
section of myclirc file.
-R, --prompt TEXT Prompt format (Default: "\t \u@\h:\d> ").
-l, --logfile FILENAME Log every query and its results to a file.
--defaults-group-suffix TEXT Read MySQL config groups with the specified
suffix.
--defaults-file PATH Only read MySQL options from the given file.
--myclirc PATH Location of myclirc file.
--auto-vertical-output Automatically switch to vertical output mode
if the result is wider than the terminal
width.
-t, --table Display batch output in table format.
--csv Display batch output in CSV 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 command and quit.
--help Show this message and exit.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2648798/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL資料庫自動補全命令MySql資料庫
- Mac 配置 oh-my-zsh 和命令列自動補全Mac命令列
- Docker 命令自動補全?要的Docker
- 終端自動補全命令
- Laravel artisan bash 命令自動補全Laravel
- fish shell 自動補全子命令
- 關於mysql語句的自動補全MySql
- mac git命令按tab鍵自動補全MacGit
- RedHat/Fedora/Centos 下bash 自動補全命令RedhatCentOS
- K8S命令自動補全方案K8S
- Linux 中 10 個有用的命令列補全例子Linux命令列
- jquery 自動補全jQuery
- Python的自動補全Python
- Autotrash:一個自動清除舊垃圾的命令列工具命令列
- 給 zsh 自定義命令新增引數自動補全
- pycharm 如何自動補全PyCharm
- mac git 自動補全MacGit
- 使用 Elasticsearch 做一個好用的日語搜尋引擎及自動補全Elasticsearch
- 刪除Chrome位址列記錄中自動補全的網址Chrome
- [譯] 自動補全規則
- Docker自動補全容器名Docker
- 分享一個自己做的小工具,百度收錄自動提交指令碼指令碼
- python之 自動補全 tabPython
- CSS 也能自動補全字串?CSS字串
- vim自動補全外掛配置
- 完善 VSCode 的 Node 自動補全VSCode
- vscode怎麼設定html標籤自動補全? vscode自動補全html的技巧VSCodeHTML
- Linux中10個有用的命令列補齊命令Linux命令列
- Python tab 命令補全,以及 vim 補全Python
- Linux設定python自動tab自動補全LinuxPython
- Python如何設定自動補全?Python
- vim自動補全外掛-NeoComplCache
- phpmyadmin主機名自動補全PHP
- 打造一個全命令列的Android構建系統命令列Android
- 分享一個線上生成簡歷的小工具
- 新手必學的使用命令列實現tab鍵自動補全功能命令列
- Solaris 預設Shell的修改以及命令列補全的設定命令列
- Autocomplete自動補全元件-HeyUI元件庫元件UI