Current Location: Home> Latest Articles> How to Delete a MySQL Database Using PHP? A Detailed Guide to PHP Functions for Deleting Databases

How to Delete a MySQL Database Using PHP? A Detailed Guide to PHP Functions for Deleting Databases

M66 2025-06-18

How to Delete a MySQL Database Using PHP? A Detailed Guide to PHP Functions for Deleting Databases

In PHP, we can use the mysql_query

The syntax above shows that $query is the SQL query string to be executed, and $link_identifier is the database connection identifier. If not provided, the function uses the last opened connection by default.

Function Parameters

Below is an explanation of the two parameters for the mysql_query function:

No. Parameter Explanation
1 Required: The SQL query string to delete the MySQL database.
2 Optional: The database connection identifier. If not specified, the last successful connection will be used.

By using the mysql_query function, you can easily delete a specified MySQL database. However, please note that this operation is irreversible, so be cautious when using it.