How to use PHP to bulk delete all tables prefixed with prefix_ in the database.
example, uniformly remove the table prefixed with "prefix_".
<?php
Sets the database connection information. Database server address, database user name, data password
mysql_connect (' Database host ', ' Database user name ', ' Database Password ');
Set the database name for the query
mysql_select_db (' database name ');
$rs =mysql_query (' Show Tables ');
while ($arr =mysql_fetch_array ($RS))
{www.jbxue.com
Set the database table prefixes to be deleted in bulk, such as: Prefix_
$TF =strpos ($arr [0], ' prefix_ ');
if ($TF ===0) {
$FT =mysql_query ("drop table $arr [0]");
if ($FT) {
echo "$arr [0] Delete succeeded! <br> ";
}
}
}
?>
Operation Example:
Create a new PHP file and save it as deletedata.php.
For example, to delete www.jbxue.com or http://www.jbxue.com/background data, the operation of two steps is OK:
1. First upload this saved deletedata.php file to your website root directory;
2. Enter directly in the Address bar: www.jbxue.com/deletedata.php or http://www.jbxue.com/deletedata.php execute this delete script.
The script displays information about all table deletion successes in the browser.
How does PHP bulk delete tables with specified prefixes under the database?