[root@kvm8 html]# mysqladmin -uroot -p123qwe drop dyw Dropping the database is potentially a very bad thing to do. Any data stored in the database will be destroyed. Do you really want to drop the 'dyw' database [y/N] y Database "dyw" dropped
mysql_query 刪除資料庫 dywphp。
[root@kvm8 html]# vim dropdb.php
[root@kvm8 html]# cat dropdb.php
<html>
<head>
<title>Deleting MySQL Database</title>
</head>
<body>
<?php
$dbhost = 'localhost:3306';
$dbuser = 'root';
$dbpass = '123qwe';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully<br />';
$sql = 'DROP DATABASE dywphp';
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not delete database: ' . mysql_error());
}
echo "Database dywphp deleted successfully\n";
mysql_close($conn);
?>
</body>
</html>
[root@kvm8 html]# php dropdb.php <html> <head> <title>Deleting MySQL Database</title> </head> <body> Connected successfully<br />Database dywphp deleted successfully </body> </html>
[root@kvm8 html]# mysql -uroot -p123qwe -e "show databases" +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+