Two ways MySQL Deletes a database

Source: Internet
Author: User

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]]# mysqladmin-u root-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 the database is potentially a very bad thing to do. Any data stored in the database would be destroyed. Do your really want to drop the ' tutorials ' database [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, connection);
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:

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.

Original address: http://www.manongjc.com/mysql/mysql_drop_database.html

Related reading:

MySQL join three table join query instance detailed

Using functions in MySQL SELECT statements

MySQL order by to sort select query result set

MySQL Select combines where sub-statement query result set

MySQL select retrieves or queries data from a table

Two ways MySQL Deletes a database

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.