MYSQL TUTORIALS - MySQL Drop Database
MySQL Drop Database
ADVERTISEMENTS
Syntax:
Parameter | Description |
---|---|
sql | Required - SQL query to create or delete a MySQL database |
connection | Optional - if not specified, then last opened connection by mysql_connect will be used. |
ADVERTISEMENTS
Drop Database using mysqladmin:
[root@host]# mysqladmin -u root -p drop TUTORIALS Enter password:******ADVERTISEMENTS
Dropping the database is potentially a very bad thing to do. Any data stored in the database will be destroyed. Do you really want to drop the 'TUTORIALS' database [y/N] y Database "TUTORIALS" droppedSyntax:
bool mysql_query( sql, connection );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\n"; mysql_close($conn); ?> </body> </html>