This article mainly introduces how php batch deletes all tables prefixed with prefix _ in the database. For more information, see
This article mainly introduces how php batch deletes all tables prefixed with prefix _ in the database. For more information, see
The following is a script to delete a table prefixed with "prefix:
The Code is as follows:
// Set the database connection information. Database server address, database user name, data Password
Mysql_connect ('database host', 'database username', 'database password ');
// Set the name of the queried Database
Mysql_select_db ('database name ');
$ Rs = mysql_query ('show tables ');
While ($ arr = mysql_fetch_array ($ rs ))
{
// Set the database table prefix to be deleted in batches, for example, prefix _
$ TF = strpos ($ arr [0], 'prefix _');
If ($ TF = 0 ){
$ FT = mysql_query ("drop table $ arr [0]");
If ($ FT ){
Echo "$ arr [0] deleted successfully!
";
}
}
}
?>
Create a new php file and save it as deletedata. php
For example, if you want to delete or background data, perform the following two steps:
1. Upload the saved deletedata. php file to the root directory of your website;
2. directly enter in the address bar: or execute the delete script to check whether the script is successfully deleted.