顺子の杂货铺
生命不息,折腾不止,且行且珍惜~

Reading table information for completion of table and column names

DMIT VPS

今天群里一同学问了一个问题,为什么在执行use db_name的时候会有如下提示:

mysql> use db_name;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

我也很好奇,于是就google了一下,得到下面一段解释,老外的:

On the first "use" command after login, MySQL scans database, tables and columns name for auto completion. If you have many db, tables it could take a while.

To avoid that, launch your client with the -A option (or –no-auto-rehash)

mysql -uroot -p -A

You could also add the disable_auto_rehash variable in your my.cnf (in the [mysql] section) if you want to disable it completely. This change does not require a reboot (it is a client, not server, variable).

意思就是说,当你登录数据库第一次使用use命令的时候,mysql要去扫描相关的数据库、表、列名的信息,然后就会出现上面那段提示,如果不想显示,可以在登录的时候加上-A or –no-auto-rehash命令,另外一种是在my.cnf里的cliect里加上no-auto-rehash参数即可。

这个扫描动作也可以理解为收集统计信息,当数据库的数据量比较大的时候,你会发现执行use db_name时会卡住一段时间,不用紧张,转身去倒杯水,回来就好啦。

赞(0)
未经允许不得转载:順子の杂货铺 » Reading table information for completion of table and column names
搬瓦工VPS

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

分享创造快乐

联系我们联系我们