What does "flush tables;" do exactly?

Long story short, I was trying to trouble an error:

User XXXXXXXXXX already has more than 'max_user_connections' active connections...

This user has  many different web sites all using one MySQL database, I had already restarted all their sites that I could find across varying web servers, and that didn't fix the error, so I then went on the MySQL server and did a "flush hosts" , that didn't help.

Then I read something along about doing:
flush tables;

So I ran that, it's still running, so far other sites using this db server aren't affected but now I'm second guessing myself and wondering if it was OK to run flush tables in the first place.

As I said, the process is still running so I'm hoping I didn't break anything.

Probably I shoudl have just restarted the MySQL service, but I didn't want to affect other users.

This is a Windows MySQL server and I could not find a command or script to kill a specific user's processes in one swoop (I did find a linux method but it involved grep and awk , so would not have worked on Windows)

Who is Participating?
Pawan KumarConnect With a Mentor Database ExpertCommented:
Flush tables - Closes all open tables, forces all tables in use to be closed, and flushes the query cache.

It also removes all query results from the query cache, like the RESET QUERY CACHE statement.

Read more at - http://dev.mysql.com/doc/refman/5.7/en/flush.html
VasAuthor Commented:
thanks, so is there any risk to running flush tables?

It's still running so I don't know if I've caused any issues yet.
Pawan KumarDatabase ExpertCommented:
It will clear the query cache content. When your caches are empty, MySQL can better utilize available memory. It can also used to unlock tables.
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

VasAuthor Commented:
For this part you said " Closes all open tables, forces all tables in use to be closed"  that sounds like a bad thing though right? (forcing tables to close)

I had run the command exactly like this with no other parameters or switches:

flush tables;

(it's still running)
Pawan KumarDatabase ExpertCommented:
Sorry for the delay in reply. Is it done?Did you face any issues?

Pls let me know.

VasAuthor Commented:
Hi, it didn't hurt anything, for an unrelated reason we had to reboot the server so it never completed fully but all is good now (the reboot must have cleared connections anyway)

Thanks so much for your help earlier
Pawan KumarDatabase ExpertCommented:
Great that everything is fine. !!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.