?php
header("Content-Type: text/html; charset=utf8");
$servername = "localhost";
$username = "username"
$password = "password"
//创建链接
$conn = new mysqli($servername,$username,$password);
if($conn->connect_error){
die("连接失败" .$conn->connect_error);
}
//创建一个为newDemo的数据库
$sql = "CREATE DATABASE newDemo";
//mysqli_query() 函数用于执行某个针对数据库的查询。
if($conn->query($sql) === TRUE){
echo "数据库创建成功";
}
else {
echo "Error creating database: " . $conn->error;
}
//关闭数据库
$conn->close();
?>