Use PHP to bulk delete all tables prefixed with prefix_ in the database _php tutorial

Source: Internet
Author: User
The following is a unified script for deleting a table with the prefix "Prefix_":
Copy CodeThe code is as follows:
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))
{
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!
";
}
}
}
?>

Create a new PHP file, save as Deletedata.php

For example, you want to delete www.aworldair.com or http://www.pro-reach.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.aworldair.com/deletedata.php or http://www.pro-reach.com/deletedata.php execution of this delete script is OK, the script will show in the browser all the table delete successful information.

http://www.bkjia.com/PHPjc/781036.html www.bkjia.com true http://www.bkjia.com/PHPjc/781036.html techarticle The following is a unified script to delete a table with the prefix "prefix_": Copy the Code as follows:? PHP//Set database connection information. Database server address, database user name, data ...

  • 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.