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;


$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";
Post a Comment