项目场景:
mysql命令行
问题描述
登录数据库切换库时感觉很卡,需要等待几秒钟。
localhost% mysql -uroot -p
mysql> use databases;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
甚至卡死。例如:
原因分析:
当数据库中表比较多,且单表又比较大时,执行这个 use databases 指令就会很卡 ( 也跟机器性能有很大关系 )
解决方案:
根据提示,连接时加入 -A 参数
localhost% mysql -A -uroot -ppassword
mysql> use databases;
Database changed
这样就很快了,简直快的飞起。
参数解释:
-A, --no-auto-rehash No automatic rehashing. One has to use ‘rehash‘ to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect.