NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Want to drop every table in your mysql database?

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 11-01-2007, 05:05 AM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Apr 2006
Posts: 254
Wuoshi is a jewel in the roughWuoshi is a jewel in the roughWuoshi is a jewel in the rough
 



Want to drop every table in your mysql database?


This script will delete every table in your database, be careful when you use it. I take no responsibility for the loss of data. Enjoy!


<html>

<body>

<?

$username="your_username";
$password="your_password";
$database="your_databse";
$host="your_hostname";

mysql_connect($host, $username, $password);
mysql_select_db($database) or die( "Unable to select database");
????: NamePros.com http://www.namepros.com/code/390831-want-drop-every-table-your-mysql.html






$query = "show tables";


$result = mysql_query($query);


while ($Row = mysql_fetch_array ($result))
{
list ($tables) = $Row;


$query2 = "DROP TABLE $tables";


$result2 = mysql_query($query2) or die(mysql_error());

}


?>

</body>
</html>
Wuoshi is offline  
Old 11-01-2007, 06:14 AM   #2 (permalink)
Danltn.com
 
Daniel's Avatar
Join Date: May 2007
Location: Danltn.com / Nottingham, UK
Posts: 1,201
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
 


Ethan Allen Fund Ethan Allen Fund
Be very careful.

This can make you lose ALL your MySQL records. - Just thought I'd point it out incase you run it without thought.

Dan
Daniel is offline  
Old 11-01-2007, 06:25 AM THREAD STARTER               #3 (permalink)
NamePros Regular
Join Date: Apr 2006
Posts: 254
Wuoshi is a jewel in the roughWuoshi is a jewel in the roughWuoshi is a jewel in the rough
 



Indeed! Only time this would be useful is when you want a clean start and don't want to drop each table manually.
Wuoshi is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 07:15 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger