登录数据库后,选择数据库时发现以下提示,
mysql> use test
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 <库名>后半天没反应,连接很慢的情况,解决办法就是 -a 方式登录数据库,不会预读库中表信息。
shell> mysql -h hostname -u username -p port -p -a
enter password:
(eg:shell> mysql -h 127.0.0.1 -u root -p 3306 -p -a)
本机登录数据库,直接执行-a也是可以的。
mysql> use test;
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> \q
bye
[root@localhost ~]# mysql -u root -p -a
enter password:
welcome to the mysql monitor. commands end with ; or \g.
your mysql connection id is 12
server version: 5.7.23 mysql community server (gpl)
copyright (c) 2000, 2018, 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.
type 'help;' or '\h' for help. type '\c' to clear the current input statement.
mysql> use test
database changed
mysql>
另一种情况,无法切换访问数据库,提示此信息。(我没遇到过,一并贴过来了解下)
由于mysql中数据库太大,导致读取预读时间太长,从而显示这个提示,如果之前都没有遇到这个问题,那么产生这个问题的原因可能是由于有改变数据库信息的操作,比如drop一个很大的表(几千万数据)而中途终止.
mysql> show processlist ; (查看进程)
上图中锁表的id为16545618,则可以使用kill命令,结束它.
mysql> kill 16545618;
删除这些锁表的情况,我的mysql就能正常访问了。
如对本文有疑问, 点击进行留言回复!!
项目实战: CMDB自动化资产扫描(搞懂这个项目 算你没白学运维)
MySQL中建表时可空(NULL)和非空(NOT NULL)的用法详解
SSD原理及Pytorch代码解读——网络架构(二):特征提取网络及总体计算过程
网友评论