超秀的 MySQL 客户端工具 MyCli ===> 支持自动补全关键字、表名、列和函数

MyCli 是 MySQL 的专用命令行客户端,可以自动补全语法高亮显示。


MyCli 是 MySQL,MariaDB 和 Percona 的命令行客户端工具,具有 自动补全 和 语法突出显示功能。

效果图:

mycli gif

兼容性:

  • Mycli 在macOS 和 Linux 上进行了测试。可运行在 Python 2.7 和 3.4+ 上。

注意:在mycli 1.9.0 中删除了 Python 2.6 支持。如果您正在运行Python 2.6,则需要安装mycli 1.8.1。


尽快安装安装体验吧 ! ! !


Windows系统:

  • 按照此博客文章中的说明在Windows上安装mycli:https://www.codewall.co.uk/installing-using-mycli-on-windows/

苹果系统:

  • 在Mac上安装mycli 使用以下命令:

brew update && brew install mycli

Linux系统:

  • Debian 和 Ubuntu 版安装方法:

  • 打开终端用以下命令安装即可:

apt安装方法:

sudo apt-get update

sudo apt-get install mycli

或pip安装方法:

pip3 install -U mycli

  • RHEL 和 Centos 版本:

  • pip安装mycli。您可以pip使用以下命令在系统上安装:

sudo yum install python -pip python-devel

  • pip 安装完成后,用以下命令安装 mycli:

sudo pip install mycli


登录MySQL方法: 

python@ubuntu:~$ mycli -uroot
Password: ********


用法:

方法一. 可以直接在终端输入以下命令:

mycli -h 192.168.1.100 -P 3306 -u root -p ******

其中:

  • -h 是需要运行 mysql 命令的服务器 IP 地址。轻松连接到远程服务器,进行数据库的「增删改查」操作。如果是连接本地数据库, 可以省略该项
  • -P 注意是大写的,即 mysql 数据库的端口,一般默认是 3306
  • -u 用户名, 本地用户名一般是 root
  • -p 注意是小写的,也可以不用在这一步明文输入密码,而是以交互的形式来输入密码,保证账户安全。

方法二. 我们也可以设置短命令来启动,命令如下

alias mysql@100='mycli -h 192.168.1.100 -P 3306 -u root -p ******'

以后就可以直接在终端使用 mysql@100 来调用 mycli 用以连接数据库了

mysql@100


配置:

  • 我们可以简单配置 mycli 以符合我们的使用习惯, 如下:
  • mycli 配置文件在 ~/.myclirc ,参考下面配置文件根据自己需要进行相应的修改与设置,比如字体颜色、自动补全、键盘使用习惯(Emacs vs Vi/Vim)

配置文件如下:

# vi: ft=dosini

[main]

# Enables context sensitive auto-completion. If this is disabled the all

# possible completions will be listed.

smart_completion = True

# Multi-line mode allows breaking up the sql statements into multiple lines. If

# this is set to True, then the end of the statements must have a semi-colon.

# If this is set to False then sql statements can't be split into multiple

# lines. End of line (return) is considered as the end of the statement.

multi_line = False

# Destructive warning mode will alert you before executing a sql statement

# that may cause harm to the database such as "drop table", "drop database"

# or "shutdown".

destructive_warning = True

# log_file location.

log_file = ~/.mycli.log

# Default log level. Possible values: "CRITICAL", "ERROR", "WARNING", "INFO"

# and "DEBUG". "NONE" disables logging.

log_level = INFO

# Log every query and its results to a file. Enable this by uncommenting the

# line below.

# audit_log = ~/.mycli-audit.log

# Timing of sql statments and table rendering.

timing = True

# Table format. Possible values: psql, plain, simple, grid, fancy_grid, pipe,

# orgtbl, rst, mediawiki, html, latex, latex_booktabs, tsv.

# Recommended: psql, fancy_grid and grid.

## 数据表的显示方式( 有三种: psql, fancy_grid, grid )

table_format = fancy_grid

# Syntax coloring style. Possible values (many support the "-dark" suffix):

# manni, igor, xcode, vim, autumn, vs, rrt, native, perldoc, borland, tango, emacs,

# friendly, monokai, paraiso, colorful, murphy, bw, pastie, paraiso, trac, default,

# fruity.

# Screenshots at http://mycli.net/syntax

# syntax_style = default

syntax_style = monokai

# Keybindings: Possible values: emacs, vi.

# Emacs mode: Ctrl-A is home, Ctrl-E is end. All emacs keybindings are available in the REPL.

# When Vi mode is enabled you can use modal editing features offered by Vi in the REPL.

key_bindings = emacs

# Enabling this option will show the suggestions in a wider menu. Thus more items are suggested.

wider_completion_menu = False

# MySQL prompt

# \t - Product type (Percona, MySQL, Mariadb)

# \u - Username

# \h - Hostname of the server

# \d - Database name

# \n - Newline

prompt = '\t \u@\h:\d> '

prompt_continuation = '-> '

# Skip intro info on startup and outro info on exit

# less_chatty = False

less_chatty = True

# Use alias from --login-path instead of host name in prompt

login_path_as_host = False

# Custom colors for the completion menu, toolbar, etc.

[colors]

# Completion menus.

## 选中关键字的颜色

# Token.Menu.Completions.Completion.Current = 'bg:#00aaaa #000000'

Token.Menu.Completions.Completion.Current = 'bg:#6A5ACD #aaffff'

## 备选关键字的颜色

Token.Menu.Completions.Completion = 'bg:#ebdbb2 #000000'

# Token.Menu.Completions.MultiColumnMeta = 'bg:#aaffff #000000'

Token.Menu.Completions.MultiColumnMeta = 'bg:#d79921 #000000'

Token.Menu.Completions.ProgressButton = 'bg:#003333'

Token.Menu.Completions.ProgressBar = 'bg:#00aaaa'

# Selected text.

Token.SelectedText = '#ffffff bg:#6666aa'

# Search matches. (reverse-i-search)

Token.SearchMatch = '#ffffff bg:#4444aa'

Token.SearchMatch.Current = '#ffffff bg:#44aa44'

# The bottom toolbar.

Token.Toolbar = 'bg:#222222 #aaaaaa'

Token.Toolbar.Off = 'bg:#222222 #888888'

Token.Toolbar.On = 'bg:#222222 #ffffff'

# Search/arg/system toolbars.

Token.Toolbar.Search = 'noinherit bold'

Token.Toolbar.Search.Text = 'nobold'

Token.Toolbar.System = 'noinherit bold'

Token.Toolbar.Arg = 'noinherit bold'

Token.Toolbar.Arg.Text = 'nobold'

# Favorite queries.

[favorite_queries]


MyCli使用帮助说明文档:

mycli --help

用法: mycli [OPTIONS] [DATABASE]
 例如:    - mycli my_database
    - mycli -u my_user_name -h my_host.com my_database
    - mycli mysql://my_user@my_host.com:3306/my_database

常用选项:
  -h, --host TEXT               数据库的主机地址.
  -P, --port INTEGER            用于连接的端口号. Honors$MYSQL_TCP_PORT.
  -u, --user TEXT               要连接数据库的用户名.
  -S, --socket TEXT             用于连接的套接字文件.
  -p, --password TEXT           要连接数据库的密码.
  --help                        查看帮助信息

非常用选项:
  --pass TEXT                   要连接数据库的密码.
  --ssh-user TEXT               连接SSH服务器的用户名.
  --ssh-host TEXT               连接SSH服务器的主机名.
  --ssh-port INTEGER            连接SSH服务器的端口.
  --ssh-password TEXT           连接SSH服务器的密码.
  --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.
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值