MySQL method to delete the database: 1. Use the "win r" key to open the "Run" window, enter "cmd" to enter the cmd command window; 2. In the cmd window, execute "mysql -u root - p" command to log in to the MySQL server; 3. Execute the "DROP DATABASE IF EXISTS database name;" command. This command is used to permanently delete all tables in the specified database.
The operating system of this tutorial: Windows 10 system, mysql version 8.0, Dell G3 computer.
When the database is no longer in use, it should be deleted to ensure that valid data is stored in the database storage space. Deleting a database is to clear the existing database from the disk space. After clearing, all data in the database will also be deleted. The "IF EXISTS" option is optional and can be set to prevent errors when deleting a database that does not exist.
In MySQL, when you need to delete a created database, you can use the DROP DATABASE statement.
DROP DATABASE statement deletes all tables in the database and permanently deletes the database. Therefore, you should be very careful when using this statement.
The following shows the syntax of the DROP DATABASE statement:
DROP DATABASE [IF EXISTS] 数据库名;
In this statement, specify the name of the database to be dropped.
MySQL will issue an error if you try to delete a database that does not exist.
To prevent errors from occurring when deleting a non-existent database, you can use the IF EXISTS option. In this case, MySQL terminates the statement without issuing any error.
Note: After MySQL is installed, the system will automatically create two system databases named information_schema and mysql. The system database stores some database-related information. If these two databases are deleted, MySQL will not work properly. .
DROP DATABASE statement to delete the database example:
1. Use the "win r" key to open the "Run" window, enter "cmd", and press Enter to enter the cmd command window
2. Log in to the MySQL server as the root user. Note that you can use your own database user instead of root.
mysql -u root -p Enter password: ********
Use the SHOW DATABASES statement to view all existing databases in the server:
SHOW DATABASES;
3. Use the DROP DATABASE statement to delete the database (test_db_del1 and test_db_del2)
DROP DATABASE test_db_del1; DROP DATABASE test_db_del2;
SHOW DATABASES;
The above is the detailed content of How to delete database in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.