Home >Database >Mysql Tutorial >[小技巧]清空MYSQL数据库的最简单办法

[小技巧]清空MYSQL数据库的最简单办法

WBOY
WBOYOriginal
2016-06-07 16:51:01900browse

复制以下代码保存为***.php 运行就OK了 lt;?php$user = quot;数据库用户名quot;; //$password = quot;数据库密码quot;;//$

复制以下代码保存为***.php 运行就OK了

$user = "数据库用户名"; //
$password = "数据库密码";//
$db_name = "数据库名";//

$link = mysql_connect("localhost:3306",$user,$password);
mysql_select_db("$db_name",$link);
echo "

正在清空数据库...";
$result=mysql_query("SHOW tables",$link);
while ($currow=mysql_fetch_array($result)) {
mysql_query("drop TABLE IF EXISTS $currow[0]");
echo $currow[0]."
";
}
echo "成功

";

?>


//把以上代码传到空间任意目录下,通过网址访问就可以了!!!

linux

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