mysql client "use database name" taking too long to execute

Go To StackoverFlow.com

1

My database contains large no of tables (more than 300 tables ) . when I execute " use database name " command on mysql command line client , its taking very long time to execute. Is there any way we can make it execute faster. ?

2012-04-05 00:19
by Jose Lona
How long is too long? 30 seconds, 5 minutes - Chris Laplante 2012-04-05 00:20
Its taking more than 5 minutes to connect. The database I am trying to connect contains more than 600 tables. I am curious that , why php-mysql client library is connecting exceptionally fast but Command line client failing to do so - Jose Lona 2012-04-05 16:34


6

You can pass the -A argument to the mysql command-line tool to make it not load database metadata when using a database.

That being said, what you're describing is usually a sign that either you have too many tables and/or columns, or your database server is overloaded. Often, it's both. Either one should be fixed.

2012-04-05 00:24
by duskwuff
Thank you for reply. I tried -A option. But still its the same issue - Jose Lona 2012-04-05 16:38
In that case, there's something very wrong with your database server - duskwuff 2012-04-05 17:07


0

I know its very old post but thought of writing about it as i also had the same problem in past and found this all

you would be having this problem when using cli while connecting mysql remotely this problem generally doesn't occur on localhost. As while using "use" command mysql check metadata of table and for loading it, it confirms host and credentials while connecting to mysql cli remotely and may be that slows down select DB, you could skip dns resolving but i don't think that will solve the problem completely

Hence "-A" tag/attribute have to pass with mysql command on connect remotely which will not load metadata while selecting DB using "USE" command.

for an example :-

mysql -A -h HOST -u USER -p

2018-03-22 16:23
by Rahul
Ads