• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2167
  • Last Modified:

Flush MySQL using PHP

Can I create a script to "FLUSH QUERY CACHE" or "FLUSH LOGS" in MySQL using PHP?

Can someone provide an example script please?

Thanks!
0
vanauden
Asked:
vanauden
2 Solutions
 
pvginkelCommented:
I take it FLUSH QUERY CACHE is an SQL statement? Wouldn't this work?

mysql_query("FLUSH QUERY CACHE");
0
 
RoonaanCommented:
Try this, although I am not sure if you are allowed to run flush query cache from other ways than terminals.

<?php
  mysql_connect('myserver','myusername','mypassword') or die('no connection');
  mysql_query('FLUSH QUERY CACHE') or die('Query failed: '.mysql_error());
?>

-r-
0
 
vanaudenAuthor Commented:
Thank you both!!

Roonaan thanks for the syntax (mysql_error) help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now