How to delete database in php mysql

藏色散人
Release: 2023-03-11 13:16:02
Original
1872 people have browsed it

php Mysql method to delete the database: first create a PHP sample file; then connect to the database; finally delete the database by executing the "DROP DATABASE xxx" statement.

How to delete database in php mysql

The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer

php mysql How to delete the database?

PHP mysqli_query function to delete the database:

Delete 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 RUNOOB&#39;;
$retval = mysqli_query( $conn, $sql );
if(! $retval )
{
    die(&#39;删除数据库失败: &#39; . mysqli_error($conn));
}
echo "数据库 RUNOOB 删除成功\n";
mysqli_close($conn);
?>
Copy after login

Note:

will not appear when using PHP script to delete the database Confirming whether to delete information will directly delete the specified database, so you should be particularly careful when deleting the database.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to delete database in php 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!