Create a MySQL Database

Create a MySQL Database

MySql database contains a number of databases.  You can create a database as per your uses, simply using  CREATE DATABASE statement

<?php
$con=mysqli_connect(“localhost”,”root”,””); // database local connection

// Connection
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}

// Create database
$sql = “CREATE DATABASE my_db”; // Query for create database
if (mysqli_query($conn, $sql))
{
echo “Database created successfully”;
}
else
{
echo “Error creating database: ” . mysqli_error($conn);
}

mysqli_close($conn); // Close database connection
?>

Next Mysql Query