关于mysql语句的自动补全

    xiaoxiao2025-09-15  36

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

    Navicat

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

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

    mycli

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

    是不是非常cool,以下记录下自己的安装过程

    根据官方文档,直接使用pip install -U mycli就可以安装了,但是系统貌似默认没有pip工具

    安装pip

    我使用的是源码安装pip1.下载源码并解压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相关的工具来管理使用数据库,我接触较少,还请指教了

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

    相关资源:数据库SQL语句自动提示插件
    最新回复(0)