How can a beginner with little to no experience in PHP create a MySQL database?

To create a MySQL database using PHP, a beginner can use the mysqli extension to connect to the MySQL server and execute SQL queries to create a new database. The mysqli_connect() function is used to establish a connection to the MySQL server, and then the mysqli_query() function can be used to execute SQL queries to create the database.

<?php
$servername = "localhost";
$username = "root";
$password = "";
$conn = mysqli_connect($servername, $username, $password);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

// Create database
$sql = "CREATE DATABASE myDB";
if (mysqli_query($conn, $sql)) {
    echo "Database created successfully";
} else {
    echo "Error creating database: " . mysqli_error($conn);
}

mysqli_close($conn);
?>