"/>
Home > Article > Backend Development > How can we delete MySQL database using PHP script?
As we all know, PHP provides us with a function called mysql_query to delete an existing database.
To illustrate this, we will delete the database named "Tutorials" with the help of PHP script in the following example -
<html> <head> <title>Deleting MySQL Database</title> </head> <body> <?php $dbhost = 'localhost:3036'; $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 TUTORIALS'; $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not delete database: ' . mysql_error()); } echo "Database TUTORIALS deleted successfully</p><p>"; mysql_close($conn); ?> </body> </html>
The above is the detailed content of How can we delete MySQL database using PHP script?. For more information, please follow other related articles on the PHP Chinese website!