MySQL Server – Explicitly State Database in Query Requirement

MySQLmysql-5.7Ubuntu

I am running mysql-client (Ver 14.14 Distrib 5.7.19) and mysql-server versions 5.7.19 with user root from localhost on Ubuntu server 16.04.2 LTS.

I have noticed that mysql doesn't return the data I'm asking unless I explicitly specify the database in the query. I have replicated the behavior below over and over again.

Can someone please explain why this is happening ?

use db1;
select database();
    db1

select count(*) from users;
    145

select * from users;
    Empty set, 28416 warnings
select * from users;
    ERROR 2006 (HY000): MySQL server has gone away

The result is changing every time you run the query above.
One empty set, one Error2006, one empty set, one Error2006,…

show warnings;
    ERROR 2013 (HY000): Lost connection to MySQL server during query
show warnings;
    Warning 1287 'COM_FIELD_LIST' is deprecated and will be removed in a future release. Please use SHOW COLUMNS FROM statement instead

There's 64 rows of this warning. I get Error2013 only the first time that I run "show warnings". There is no pause or delay.
All subsequent runs return the same 64 rows.

select * from db1.users;

This returns the full table (145 rows) with no problems whatsoever.

Best Answer

It sounds like 5.7.19 jumped the gun.

----- 2016-02-05 5.7.11 General Availability -- Functionality Added or Changed -- -----

The mysql_kill() ( /doc/refman/5.7/en/mysql-kill.html ), mysql_list_fields() ( /doc/refman/5.7/en/mysql-list-fields.html ), mysql_list_processes() ( /doc/refman/5.7/en/mysql-list-processes.html ), and mysql_refresh() ( /doc/refman/5.7/en/mysql-refresh.html ) C API functions are deprecated and will be removed in a future version of MySQL. The same is true of the corresponding COM_PROCESS_KILL, COM_FIELD_LIST, COM_PROCESS_INFO, and COM_REFRESH client/server protocol commands. Instead, use mysql_query() ( /doc/refman/5.7/en/mysql-query.html ) to execute a KILL ( /doc/refman/5.7/en/kill.html ), SHOW COLUMNS ( /doc/refman/5.7/en/show-columns.html ), SHOW PROCESSLIST ( /doc/refman/5.7/en/show-processlist.html ), or FLUSH ( /doc/refman/5.7/en/flush.html ) statement, respectively.

Recommend you post a bug with bugs.mysql.com .