Creation or erasure of information bases in MariaDB requires advantages, ordinarily, simply given to root clients or administrators. Under these records, you have two alternatives for erasing a data set: the mysqladmin double and a PHP content.
Note that erased information bases are gone, so practice care in playing out this activity. Moreover, PHP contents utilized for erasure don't speedy you with an affirmation before the cancellation.
mysqladmin binary
The accompanying model exhibits how to utilize the mysqladmin paired to erase a current data set −
[root@host]# mysqladmin -u root -p drop PRODUCTS
Enter password:******
mysql> DROP PRODUCTS
ERROR 1008 (HY000): Can't drop database 'PRODUCTS'; database doesn't exist
Mistake 1008 (HY000): Can't drop information base 'Items'; data set doesn't exist
PHP Drop Database Script
PHP utilizes the mysql_query work in erasing MariaDB information bases. The capacity utilizes two boundaries, one discretionary, and returns either an estimation of "valid" when effective, or "bogus" when not.
Syntax
Survey the accompanying drop information base content linguistic structure −
bool mysql_query( sql, connection );
The depiction of the boundaries is given underneath −
Sr.No | Parameter & Description |
---|---|
1 |
sql This required parameter consists of the SQL query needed to perform the operation. |
2 |
connection When not specified, this optional parameter uses the most recent connection used. |
Attempt the accompanying model code for erasing an information base −
<html>
<head>
<title>Delete a MariaDB 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 PRODUCTS';
$retval = mysql_query( $sql, $conn );
if(! $retval ){
die('Could not delete database: ' . mysql_error());
}
echo "Database PRODUCTS deleted successfully\n";
mysql_close($conn);
?>
</body>
</html>
On effective cancellation, you will see the accompanying yield −
mysql> Database PRODUCTS deleted successfully