Home > Article > Backend Development > How to delete database in php mysql
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.
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 = 'localhost'; // mysql服务器主机地址 $dbuser = 'root'; // mysql用户名 $dbpass = '123456'; // mysql用户名密码 $conn = mysqli_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('连接失败: ' . mysqli_error($conn)); } echo '连接成功<br />'; $sql = 'DROP DATABASE RUNOOB'; $retval = mysqli_query( $conn, $sql ); if(! $retval ) { die('删除数据库失败: ' . mysqli_error($conn)); } echo "数据库 RUNOOB 删除成功\n"; mysqli_close($conn); ?>
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!