Whirlwind
Whirlwind

Reputation: 13675

Running a "show databases;" query resulted in "No database selected" error, but only for the first time

What I did is navigated to the folder where the MySQL is installed:

cd /usr/local/mysql/bin/

then logged in:

$ ./mysql -u root -p

and tried to see databases available:

mysql-> show databases;

So I got this error:

ERROR 1046 (3D000): No database selected

Now that was confusing... And that happened only once. I tried to execute the same query like 30 seconds later (while I was still logged in), and I got the normal result - the list of available databases.

What caused the query failure at first attempt ? I have tried to repeat the steps, and I can't reproduce the issue anymore.

I am on OSX Sierra.

Upvotes: 0

Views: 176

Answers (2)

xc218m
xc218m

Reputation: 69

I am not 100percent sure but this is a bug in older mysql servers that require to SELECT a database prior to use any other queries althogh they are"meta" queries.

Upvotes: 1

Rahul
Rahul

Reputation: 77926

That's a wired thing to happen. What happen when you use mysqlshow command like below. does it lists out all the databases?

mysqlshow -u root -p

Upvotes: 0

Related Questions