Home  >  Article  >  Backend Development  >  How to delete all data tables in mysql database_PHP tutorial

How to delete all data tables in mysql database_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:59:31871browse

A simple php code can easily delete all data tables in the entire database. Isn’t this too dangerous? Let’s take a look at the deletion method.

$hostname ='localhost';
$user = 'user';
$password = 'password';
$dbname = 'dbname';

$connect = mysql_connect($hostname,$user,$password);
mysql_select_db($dbname);

$result = mysql_query("show table status from ".$dbname,$connect);

echo 'ing....
';

while($data=mysql_fetch_array($result)) {
echo $data["Name"].'
';
mysql_query("drop table ". $data["Name"]);
}

echo 'finished';
?>
The code is as follows
 代码如下 复制代码

$hostname ='localhost';
$user = 'user';
$password = 'password';
$dbname = 'dbname';

$connect = mysql_connect($hostname,$user,$password);
mysql_select_db($dbname);

$result = mysql_query("show table status from ".$dbname,$connect);

echo 'ing....
';
 
while($data=mysql_fetch_array($result)) {
 echo $data["Name"].'
';
 mysql_query("drop table ". $data["Name"]);
}
 
echo 'finished';
?>

Copy code

Note: After reading this code, should you guys deal with the security and user permissions of your mysql server? http://www.bkjia.com/PHPjc/631315.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/631315.html
TechArticle
A simple php code can easily delete all data tables in the entire database. Isn’t this too dangerous? , let’s take a look at the deletion method. The code is as follows Copy the code ?...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn