use database 切換提示You can turn off this feature to get a quicker startup

dba_sam發表於2021-06-29

use database 很慢/You can turn off this feature to get a quicker startup with –A


mysql> use information_schema
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


當切換到某個庫時,經常會出現上面資訊,意思是預讀這個庫中表以及表列資訊。

但是當庫中表很多,表中資料很大時,就會出現執行use <庫名>後半天沒反應,連線很慢的情況

 

解決辦法:

上面其實已經有提示了(You can turn off this feature to get a quicker startup with -A)

就是在登陸連線mysql時使用-A引數,這樣就不會預讀庫中表資訊了,能提高連線庫的速度.

 

shell> mysql -h hostname -u username -P port -p -A

Enter password:

MySQL -A引數含義:

shell> mysql --help

  -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.

 

例子:

shell> mysql -h 127.0.0.1 -u root -P 3306 -p

Enter password:

mysql> use information_schema;
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> exit
Bye


shell> mysql -h 127.0.0.1 -u root -P 3306 -p

Enter password:

mysql> use information_schema;
Database changed        


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70000068/viewspace-2777491/,如需轉載,請註明出處,否則將追究法律責任。

相關文章