关于mysql语句的自动补全

最近接触数据库较多,在使用总经常要重复的输入命令查看一些信息,默认的cli不支持语句自动补全,很是不方便,找了一些更方便的操作数据库的工具,在此分享

Navicat

对于不需要实际操作系统,比如测试人员,只关心数据库,现在普遍都使用的是Navicat,提供可视化的界面,上手即会用。一些特点如下

  • 同时连接多个数据库
  • 可视化数据库/表
  • 直接导入sql文件
  • sql语句自动补全
  • 可视化备份
    以上是个人总结,由于实际工作中很少用此工具连接数据库,他的优势应该还有待补充

mycli

mycli是一个支持mysql语句自动补全和语法高亮的MySQL客户端工具
项目地址:https://github.com/dbcli/mycli
来简单看下效果:
image

是不是非常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
人后安装mycli
pip install mycli
如果不可用,可能需要高版本的Python
pip3 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相关的工具来管理使用数据库,我接触较少,还请指教了

文中若有不当和理解错误之处,还请斧正~

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值