mysql 命令行補全工具 myclimysql
前言git
咱們在鏈接mysql數據庫的時候,大多數狀況下是使用gui圖形界面的工具的。可是,有時候鏈接數據庫仍是命令行方便,因此,咱們一般都須要掌握一點命令行操做數據庫的基礎。github
這裏推薦一篇文章給你們看Mysql命令大全,這裏包含了絕大多數咱們須要用到的mysql命令。sql
可是,默認的mysql命令行是不支持補全的,而且很討厭的是,咱們輸入了錯誤的命令以後,因爲命令行操做習慣,按ctrl+c想要取消的時候,tmd已經退出了mysql命令行工具。只能再次鏈接。想要刪除錯誤的命令只能 ctrl+a ctrl+u進行刪除。或者一直按ctrl+w進行刪除。數據庫
還有,每一個命令必須以;分號結尾,而我這樣的馬大哈總是忘記。django
最重要的是,這玩意兒不支持補全!我這樣的人,沒有補全怎麼操做命令行哦!ubuntu
今天看到github上有一個開源項目叫mycli,感受很是好,安裝使用了一下,果真牛逼,已經克服了個人Mysql命令行操做恐懼了!所以,推薦給你們!windows
安裝app
官方網站:http://mycli.net
github地址:https://github.com/dbcli/myclisocket
操做演示
mac安裝方法
$ brew update && brew install mycli
ubuntu安裝命令
sudo apt-get install mycli
arch安裝命令
sudo pacman -S mycli
windows未測試,手頭上沒有windows系統。
使用方法
$ mycli --help
Usage: mycli [OPTIONS] [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
--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 \u@\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
--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 query to the database.
--help Show this message and exit.
鏈接數據庫
$ mycli local_database
$ mycli -h localhost -u root app_db
$ mycli mysql://amjith@localhost:3306/django_poll
若是你熟練使用Mysql命令行,那麼使用這個工具沒有任何問題。若是你不熟練,使用這個工具能夠跟快的使你熟練!