How to Drop MySQL Database?

How to Drop MySQL Database?

We can drop/delete/remove MySQL database using DROP DATABASE command. After executing this command it deletes all the tables of the database.

Syntax:DROP DATABASE database_name;

MySQL

      <?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);

if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully<br />';
$sql = 'DROP DATABASE myDB';
$retval = mysql_query( $sql, $conn );

if(! $retval ) {
die('Could not delete database: ' . mysql_error());
}
echo "Database myDB deleted successfullyn";
mysql_close($conn);
?>
Post a Comment