MySQL的auto-rehash自动补全功能

Posted bisal(Chen Liu)

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL的auto-rehash自动补全功能相关的知识,希望对你有一定的参考价值。

我们配置mysql时,可能会注意到有一个参数叫"auto-rehash"或者"no-auto-rehash",示例可参考《GreatSQL(/MySQL)的配置文件模板样例》,他是什么意思?

"auto-rehash"其实就是自动补全的含义,他可以读取表信息和列信息,就像我们在Linux命令行里输入命令的时候,使用tab键进行自动补全的操作一样,默认配置是"no-auto-rehash",不进行自动补全。同时,可以通过命令行启用或者关闭auto-rehash功能,例如不启用就可以通过mysql -h连接时指定-A选项,还可以通过mysql连接数据库时使用--auto-rehash来设定使用此选项,开启tab补齐功能。

但如果是Windows的环境中,不支持自动补全的功能,示例可参考《GreatSQL(/MySQL)的配置文件模板样例》,

[mysql]
auto-rehash
edit: My apologies. I have found some references that the tab-completion feature in mysql client works only on UNIX/Linux. It does not work on Windows.

update: The reason for this is mentioned briefly in MySQL bug #4731:

[31 Jul 2004 12:47] Sergei Golubchik

I just downloaded 4.0.15 - command completion in mysql.exe is NOT working, as expected. It was never working in mysql.exe because we were not able to make readline to compile with VC++.

mysqlc.exe is a cygwin build, and it is linked with readline.

Explanation: GNU readline is a standard open-source library for handling user input. The MySQL team uses the readline library, but they are not its author. From the above comment, I understand that they were unsuccessful in compiling the readline library on Windows with Microsoft Visual C++, the tool they use to build the MySQL product. Some open-source projects have not been made fully compatible with the Microsoft Windows environment.

At one time in the past, the MySQL product provided an alternative client they called mysqlc.exe, which they compiled with the cygwin toolset on Windows, but they don't provide this anymore. The cygwin toolset includes the readline library, so it was possible to compile the mysqlc.exe client with support for tab-completion.

So in theory, if you are really intrepid, you could download the cygwin toolset including the readline library, then download the MySQL source code and build it using cygwin. Then you should have a mysql client program that can perform tab-completion. But this sounds like a lot of work even for someone who is familiar with building MySQL from source.

数据库客户端软件有时候还是很方便的,因为都是敲指令,所以就可以配置很多快捷方式,MySQL如此,Oracle的sqlplus更是这样,可以参考《让你的sqlplus支持历史指令的快速检索》。

如果您认为这篇文章有些帮助,还请不吝点下文章末尾的"点赞"和"在看",或者直接转发pyq,

近期更新的文章:

MySQL借助于LIMIT和OFFSET实现的高性能分页功能

MySQL中"更新时间"字段的更新时点问题

最近碰到的一些问题

磁盘空间分配的初次尝试

Oracle的online index rebuild

近期的热文:

"红警"游戏开源代码带给我们的震撼

文章分类和索引:

公众号1000篇文章分类和索引

以上是关于MySQL的auto-rehash自动补全功能的主要内容,如果未能解决你的问题,请参考以下文章

mysql命令行知多少

Mysql常用配置及优化

mysql命令行参数

数据库基础操作

linux 下如何进入 mysql 命令行?

mysql命令常用参数实例讲解