Use php to batch delete all tables prefixed with prefix _ in the database

Source: Internet
Author: User
This article mainly introduces how php batch deletes all tables prefixed with prefix _ in the database. For more information, see the following script to delete tables 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 the back-end data of www.aworldair.com or http://www.pro-reach.com/, you can do this in two steps:

1. Upload the saved deletedata. php file to the root directory of your website;

2. enter the following in the address bar: Success.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.