Linux/Unix环境下使用命令行,使用tab键命令补全、路径补全非常省心。mysql命令,是后端开发过程中最常用的,经常手写SQL语句 ,需要填写表名、字段名。 表多,字段多场景下容易忘记。为解决这一痛点,分享一下mysql命令 特殊选项。
--auto-rehash
[long@iZuf675xet9v7jiefrscgmZ ~]$ mysql --help
mysql Ver 14.14 Distrib 5.5.56, for Linux (x86_64) using readline 5.1
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Usage: mysql [OPTIONS] [database]
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
(Defaults to on; use --skip-auto-rehash to disable.)
1、全局开启功能
my.cnf配置文件
[mysql]
auto-rehash
2、命令行使用
直接在mysql连接命令,加上“--auto-rehash”即可。
/usr/bin/mysql -h地址 -uroot -p密码 --database=数据库名称 --default-character-set=utf8 -A --auto-rehash
执行效果展示