Collections:
Deleting an Existing Database in MySQL
How To Drop an Existing Database in MySQL?
✍: FYIcenter.com
If want to drop an existing database from the MySQL server, you can use the DROP DATABASE statement. Here is a good example of dropping an existing database:
$con = mysql_connect('localhost:8888', 'dev', 'iyf');
$sql = 'DROP DATABASE fyi';
if (mysql_query($sql, $con)) {
print("Database fyi dropped.\n");
} else {
print("Database drop failed with error:\n");
print(mysql_errno($con).": ".mysql_error($con)."\n");
}
mysql_close($con);
?>
If you run this script, you will get something like this, if "dev" does not have privilege to drop database:
Database drop failed with error: 1044: Access denied for user 'dev'@'%' to database 'fyi'
⇒ Selecting an Existing Database in MySQL
⇐ Retrieving Execution Error Message in MySQL
2017-10-23, 2692🔥, 0💬
Popular Posts:
How To Divide Query Output into Multiple Groups with the GROUP BY Clause in SQL Server? Sometimes, y...
What To Do If the StartDB.bat Failed to Start the XE Instance in Oracle? If StartDB.bat failed to st...
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the...
How To Enter Unicode Character String Literals in SQL Server Transact-SQL? Unicode characters are mu...