MySQL flush tables - Current database or every database? MySQL flush tables - Current database or every database? mysql mysql

MySQL flush tables - Current database or every database?


It's all databases.


I tried to look this up but I couldn't find an authoritative answer either.

  • I looked in the manual, as you did.
  • I found the MySQL Internals documentation on FLUSH TABLES, but it doesn't say specifically.
  • I even read the source code in mysql_server/sql/sql_base.cc but couldn't find the answer quickly.

I assume the answer is one of those things that the developers feel is so obvious that they never need to say it.

According to the internals doc, the MySQL table cache holds a list of of most recently used tables. There is no mention of database-specific table caches, there seems to be only one table cache in the MySQL Server.

FLUSH TABLES is described as forcing all open tables (those in the table cache) to be closed. There is no mention of this being limited to one database, but you can specify individual tables in the arguments to FLUSH TABLES. So likewise, I assume this applies to the whole table cache by default, and therefore to all databases with open files on the MySQL Server.


when you do just a mysql_connect and then "show tables" for example-> mysql_error(): No Database selected

with "flush tables" there is no mysql_error, so i think the answer isevery database