關於mysql語句的自動補全
最近接觸數據庫較多,在使用總經常要重複的輸入命令查看一些信息,默認的cli不支持語句自動補全,很是不方便,找了一些更方便的操作數據庫的工具,在此分享
Navicat
對於不需要實際操作係統,比如測試人員,隻關心數據庫,現在普遍都使用的是Navicat,提供可視化的界麵,上手即會用。一些特點如下
- 同時連接多個數據庫
- 可視化數據庫/表
- 直接導入sql文件
- sql語句自動補全
- 可視化備份 以上是個人總結,由於實際工作中很少用此工具連接數據庫,他的優勢應該還有待補充
mycli
mycli是一個支持mysql語句自動補全和語法高亮的MySQL客戶端工具
項目地址:https://github.com/dbcli/mycli
來簡單看下效果:
是不是非常cool,以下記錄下自己的安裝過程
根據官方文檔,直接使用pip install -U mycli
就可以安裝了,但是係統貌似默認沒有pip工具
安裝pip
我使用的是源碼安裝pip
1.下載源碼並解壓
2.python setup.py install
安裝pip工具
安裝mycli
需要Python開發環境
執行yum install python-devel
,沒有這個環境的話,可能會報編譯錯誤或cannot find -lpython2.6
人後安裝myclipip install mycli
如果不可用,可能需要高版本的Pythonpip3 install mycli
至此安裝完成
測試下,用法和原生mysql連接方式類似
mycli -h localhost -u root app_db
$ 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.
暫且就這兩工具吧~實際項目中可能還會用到PHPadmin和其他一些PHP相關的工具來管理使用數據庫,我接觸較少,還請指教了
文中若有不當和理解錯誤之處,還請斧正~
最後更新:2017-04-15 12:31:00