How to create database in MYSQL [Updated in 2017]

Basic learning about how to create database in MYSQL. See the following example of creating database.

<html>
<head>
<title>MySQL Database Creation</title>
</head>
<body>
<?php
$dbhost = “localhost”;
$dbuser = “root”;
$dbpass = “rootpassword”;
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die(‘Could not connect: ‘ . mysql_error());
}
echo ‘Connected successfully<br />’;
$sql = ‘Create Database’;
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die(‘Could not connect database: ‘ . mysql_error());
}
echo “Database created successfully”;
mysql_close($conn);
?>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *