MySQL Drop DB Delete database command instance explain _mysql

Source: Internet
Author: User
Tags mysql drop database

The MySQL Drop database command is used to delete a database, and if you attempt to delete a nonexistent database using the drop DATABASE command, you receive this error: Error 1008 (HY000): Can ' t drop database ' Tutorial_database '; Database doesn ' t exist, this article introduces you to MySQL drop database usages.

First, we need to connect to the database server before we delete the database using drop db.

We can log on to the MySQL server using the following command:

Mysql-u root-p

-U represents the username identifier, root indicates the user name value, and-p represents the password, because the password is not entered after-p, so MySQL prompts for the password. Enter your current password to complete the login.

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

After connecting to the MySQL database server, we can delete any database that exists in the database server.

Just need a simple command to delete the database in MySQL, but be careful; Delete database cannot be restored, MySQL command 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, use the following command:

DROP DATABASE IF EXISTS tutorial_database;

If the Tutorial_database database exists in the database server, the above command deletes the database. Otherwise, no action is made.

After the delete command has been executed, we can use the show database command to see if the databases have been deleted.

To view the list of databases simply issue 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)

' Above is the MySQL drop database to delete databases command instances of data collation, follow-up continue to supplement the relevant information thank you for your support of 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.