Mysql Delete Database Drop db Detailed introduction _mysql

Source: Internet
Author: User
Tags mysql delete mysql delete database php script

Mysql Delete Database Drop db

Method-: Download Delete using cmd mode

mysql> drop Database School;

This name deletes the school database. However, an error occurs if the school database does not exist. So the complete statement should write this:

Mysql> drop database if exists school;

Method Two: PHP script delete Database

In PHP, we can use the Mysql_query function to execute the SQL statement. So when we delete the database, we can use the mysql_query to execute the delete command directly.

<?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 Successfullyn";
Mysql_close ($conn);
? >

Thank you for reading, I hope to help you, thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.