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.

<title>MySQL Database Creation</title>
$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”;

Leave a Reply

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