MySQLi Create Database

The CREATE DATABASE statement is used to create a database in MySQL.

Below the example to create a database:

<?php
   $conn  = mysqli_connect('localhost:3306', 'user_name', 'password');
   if(! $conn) {
       die('Could not connect: ' . mysqli_error());
   }
   $sql = "CREATE DATABASE `db_nexladder`";
   if (mysqli_query($conn, $sql)) { 
     echo "Database created Successfully";
   } else { 
     echo "Error:". mysqli_error($conn); 
   }
   mysqli_close($conn);
 ?>

Output: Database created Successfully

Open the MySQL console and write down password. You'll get the following

mysqli create database 1

Let's take an example to create a database name "db_nexladder".

It'll look like:

mysqli create database 2