MySQL Create Database

Last Updated by Yogesh Khanna 13-Mar-20

0 1354


A database is the container of tables. For creating a MYSQL Database firstly, we need to make connection with the server.

The statement used for database creation is 'CREATE DATABASE'

<?php

$servername="localhost";
$username="user";
$password="pass";

//Create connection
$connect=mysql_connect($servername,$username,$password); or die("Connection failed");

//After connecting to mysql, create Database
$db="CREATE DATABASE user";

if(mysql_query($connect,$db))
{
echo "Database Successfully Created";
}
else
{
echo "Database Creation Failed";
}

?

To check your database, go to localhost panel:

http://localhost/phpmyadmin


Share:


Discount Coupons



Leave a Reply


Comments
    Waiting for your comments