MySQL Delete Database

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

MySQL Delete Database To delete a database using mysqladmin

Using a normal user to log on to the MySQL server, you may need specific permissions to create or delete the MySQL database.

So here we are using the root user login, the root user has the highest privileges, you can use the MySQL mysqladmin command to create a database.

It is important to be careful when you delete a database, because all data disappears after the delete command is executed.

The following instance deletes the database tutorials (the database was created in the previous section):

[[email protected]]#--p Drop tutorialsEnter password:* * * * * *    

After you execute the delete database command above, a prompt box appears to confirm that the database is actually deleted:

Dropping is does.  Any in the database would be destroyed.  Do' tutorials '[y/N] yDatabase"Tutorials" dropped  
Delete a database using a PHP script

PHP uses the Mysql_query function to create or delete MySQL databases.

The function has two parameters, returns TRUE on successful execution, or FALSE.

Grammar
BOOL mysql_query( sql,);    
Parameters Description
Sql Necessary. Specifies the SQL query to send. Note: The query string should not end with a semicolon.
Connection Optional. Specifies the SQL connection identifier. If not specified, the previous open connection is used.
Instance

The following example demonstrates using the PHP mysql_query function to delete a database:

<title>Deleting MySQL Database</title><body><?Php$dbhost= ' localhost:3036 ';$dbuser= ' Root ';$dbpass= ' Rootpassword ';$conn=Mysql_connect($dbhost,$dbuser,$dbpass);If(!$conn){ Die(' Connection failed: ' .Mysql_error());}Echo' Connection succeeded <br/> ';$sql= ' DROP DATABASE Tutorials ';$retval=Mysql_query( $sql , $conn if (! $retval ) { die ( ' delete database failed: '  Mysql_error ()); }echo  "database tutorials Delete succeeded \ n" mysql_close ( $conn ?></body>               

Note: When you delete a database using a PHP script, there is no confirmation of whether to delete the information or delete the specified database, so you should be careful when deleting the database.

MySQL Delete Database

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.