You can create/drop any database using MySQL mysqladmin binary. It’s very important to understand that If you drop a database, that means to delete any database then all the data in it will be deleted forever.So always think twice before dropping a database.
Here is an example to Drop Database In MySQL Database in the previous chapter:
[[email protected]]# mysqladmin -u root -p drop Database tutorials
First of all, this will provide a warning and it will confirm if you really want to delete this database or “no”.
Any data stored in the database will be destroyed.
Do you really want to drop the ‘ Database tutorials‘ database [y/N] y
Database ” Database tutorials” dropped
Drop Database using PHP Script:
PHP uses the mysql_query function in order to either create or delete a MySQL database.
bool mysql_query( sql, connection );
|sql||Required – SQL query either to create or delete a MySQL database|
|connection||Optional – if not specified, then last opened connection will be used by mysql_connect.|
An example to delete a database:
$sql = ‘DROP DATABASE TUTORIALS’;
$result = mysql_query( $sql, $con );
if(! $result )
die(‘Could not delete database: ‘ . mysql_error());
echo “Database TUTORIALS deleted successfully\n”;