Home > Database > Mysql Tutorial > What is the command to delete a database in MySQL?

What is the command to delete a database in MySQL?

青灯夜游
Release: 2020-08-17 15:14:06
Original
8500 people have browsed it

The command to delete a database is: "DROP DATABASE database name;"; for example, "drop database student;" is to delete the database named student. The "DROP DATABASE" statement can be used to delete a database.

What is the command to delete a database in MySQL?

Use the drop command to delete the database

drop database# The ## statement can be used to delete the database.

drop database command format:

drop database <数据库名>;
Copy after login

For example, to delete the database named student:

mysql> drop database student;
Copy after login

Expand knowledge

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.

Grammar

mysqli_query(connection,query,resultmode);
Copy after login

What is the command to delete a database in MySQL?

Example: Use the mysqli_query() function to delete the database

<?php
$dbhost = &#39;localhost&#39;;  // mysql服务器主机地址
$dbuser = &#39;root&#39;;            // mysql用户名
$dbpass = &#39;123456&#39;;          // mysql用户名密码
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
    die(&#39;连接失败: &#39; . mysqli_error($conn));
}
echo &#39;连接成功<br />&#39;;
$sql = &#39;DROP DATABASE student&#39;;
$retval = mysqli_query( $conn, $sql );
if(! $retval )
{
    die(&#39;删除数据库失败: &#39; . mysqli_error($conn));
}
echo "数据库 RUNOOB 删除成功\n";
mysqli_close($conn);
?>
Copy after login

Related recommendations: "

PHP Tutorial》、《mysql tutorial

The above is the detailed content of What is the command to delete a database in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template