我有一个MySQL数据库,以前工作得很好,但现在它启动时死缓。 当我input时
$> mysql -u foo bar
在得到提示之前,我会收到以下通常的消息,时间为30秒左右:
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
当然,我试了一下,速度快了很多:
$> mysql -u foo bar -A
但是为什么我要在正常的启动中等这么久? 这不是一个很大的数据库(编辑:<10 MB),并且数据似乎没有损坏(启动后一切都看起来不错)。 我没有其他客户端在同一时间连接到MySQL服务器(只有一个进程显示命令show full processlist ),我已经重新启动mysqld服务。
这是怎么回事 ?
添加以下内容到你的[mysql](注意它不会以d结尾),这将大大加快你的响应时间:
no-auto-rehash
我认为这个问题来自于自动rehashfunction
我今天试了一下
在mysql提示符下,我input了
mysql> desc outbound_
我打了两次选项卡,得到以下
mysql> desc outbound_ outbound_call_id outbound_log.ext outbound_log.template_id outbound_log outbound_log.failed outbound_log.transfer_connected outbound_log.DealerVoiceProviderType outbound_log.icallclick_alert outbound_log.transfer_duration outbound_log.VoipCallStatusType outbound_log.isService outbound_log.transfer_ended outbound_log.VoipTransferStatusType outbound_log.lead_id outbound_log.transfer_ext outbound_log.call_duration outbound_log.outbound_log_id outbound_log.transfer_phone outbound_log.call_ended outbound_log.phone outbound_log.transfer_started outbound_log.call_started outbound_log.postback outbound_log.transfer_status outbound_log.call_type outbound_log.recording_url outbound_log.vehicle_id outbound_log.called outbound_log.remote_call_id outbound_log_id outbound_log.callnote_synced outbound_log.sales_id outbound_log.dealer_id outbound_log.scheduled mysql> desc outbound_
每个数据库和表格都提供给我select
很明显,mysql客户端必须读取information_schema数据库。 如果你的mysql实例包含很多InnoDB表,我可以看到auto-rehash拖延mysql客户端,直到它可以读取information_schema数据库。
谢谢大家,我find了我的问题的答案。 数据库中的一个表不能被访问:
mysql> show columns from foo; ERROR 1033 (HY000): Incorrect information in file: './db/foo.frm'
关联的foo.frm文件不能再被读取。
$> cat foo.frm cat: foo.frm: input/output error
磁盘故障:/ Mysql启动时间太长,因为它试图从该文件访问数据。