Home > Backend Development > PHP Problem > How to delete database in php

How to delete database in php

angryTom
Release: 2023-02-27 13:24:02
Original
4786 people have browsed it

How to delete database in php

How to delete a database in php

1. First check which databases there are

How to delete database in php

2. Use php to delete test2

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

3. Run the php program

How to delete database in php

3. Check the database again

How to delete database in php

test2 is gone and deleted successfully!

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to delete database in php. 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