Mysql drop database delete database command instance description, drop instance description

Source: Internet
Author: User
Tags mysql drop database

Mysql drop database delete database command instance description, drop instance description

The mysql drop database Command is used to delete a database. If you try to use the drop database Command to delete a database that does not exist, you will receive the ERROR: ERROR 1008 (HY000 ): can't drop database 'tutorial _ database'; database doesn' t exist. This article introduces the mysql drop database instance.

Before using drop database to delete a database, we need to connect to the database server.

Run the following command to log on to the mysql server:

Mysql-u root-p

-Utable indicates the user name identifier. root indicates the user name value, and-p indicates the password. Because-p does not enter the password, MySQL will prompt you to enter the password. Enter your current password to log on.

If you need to change the password in the database, you can read the text "Modify MySQL password through command line" on this website.

After connecting to the mysql database server, we can delete any existing databases in the database server,

You only need a simple command to delete the database in MySQL, but be careful. Deleting the database cannot be recovered. The mysql Command is as follows:

Drop database tutorial_database;

If the database tutorial_database does not exist, you will receive this error:

ERROR 1008 (HY000): Can't drop database 'tutorial _ database'; database doesn' t exist

To avoid this error, run the following command:

Drop database if exists tutorial_database;

If the tutorial_database database exists on the database server, the preceding command deletes the database. Otherwise, no operation is performed.

After executing the DELETE command, we can run the show database command to check whether the database has been deleted.

To view the Database List, run the following command:

Show databases;

Your results should be similar to this:

Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Test |
+ -------------------- +
4 rows in set (0.00 sec)

'The above is how mysql drop database deletes database Command instances. We will continue to add relevant information later. 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.