The code for php to delete a database is "drop database
;", where the drop command is used to delete the database, and the value of the parameter "database" specifies the name of the database to be deleted.
Recommended: "PHP Video Tutorial"
MySQL Delete Database
Use an ordinary user to log in to the MySQL server. You may need specific permissions to create or delete a MySQL database, so we use the root user to log in. The root user has the highest permissions.
Be very careful when deleting the database, because all data will disappear after executing the delete command.
drop command deletes the database
drop command format:
drop database <数据库名>;
For example, to delete a database named RUNOOB:
mysql> drop database RUNOOB;
Use mysqladmin to delete the database
You can also use the mysql mysqladmin command to execute the delete command in the terminal.
The following example deletes the database RUNOOB (the database has been created in the previous chapter):
[root@host]# mysqladmin -u root -p drop RUNOOB Enter password:******
After executing the above delete database command, a prompt box will appear to confirm whether the database is really deleted. :
Dropping the database is potentially a very bad thing to do. Any data stored in the database will be destroyed. Do you really want to drop the 'RUNOOB' database [y/N] y Database "RUNOOB" dropped
Use PHP script to delete database
PHP uses the mysqli_query function to create or delete a MySQL database.
This function has two parameters and returns TRUE when executed successfully, otherwise it returns FALSE.
Syntax
mysqli_query(connection,query,resultmode);
Parameters
connection required. Specifies the MySQL connection to use.
query Required, specifies the query string.
resultmode
Optional. a constant. Can be any of the following values:
MYSQLI_USE_RESULT(如果需要检索大量数据,请使用这个) MYSQLI_STORE_RESULT(默认)
The above is the detailed content of php code to delete database. 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

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

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