Home  >  Article  >  php教程  >  删除mysql数据库所有数据表方法

删除mysql数据库所有数据表方法

WBOY
WBOYOriginal
2016-06-13 10:03:43881browse

一段简单的php代码就可以方便的删除整个数据库的所有数据表,这是不是太危险了呢,下面我们来看看删除方法吧。

 代码如下 复制代码

$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';
?>

注:看了这代码后各位哥们是不是应该对你的mysql服务器的安全与用户权限作一下处理呢。

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