Use php to batch delete all prefixes under the database as prefix_Table

  • 2021-06-28 12:00:27
  • OfStack

Here is Unit 1 deleting the prefix "prefix_"Script for table:
 
<?php 
// Set up 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)) 
{ 
// Set 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 successful! <br>"; 
} 
} 
} 
?> 

Create a new php file and save it as deletedata.php

For example, if you want to delete background data from www.aworldair.com or http://www.pro-reach.com/the two steps are ok:

1. First upload this saved deletedata.php file to the root directory of your website;

2. Enter directly in the Address bar: www.aworldair.com/deletedata.php or http://www.pro-reach.com/deletedata.php Execute this deletion script to OK, which will display the successful deletion information for all tables in the browser.

Related articles: