PHP Create a MySQL Database :
The "CREATE DATABASE db_name"
command is used to create a database in MySQL.
To learn more about PHP & MySQL database, we will create a Database. Later we will use it to insert or retrieve data from this database.
Syntax :
CREATE DATABASE new_db;
In this example first, we will create a database server connection. Then, we can create a new database using the above command/statement.
Example (MySQLi Object-oriented)
Output :
Example (MySQLi Procedural):
output :
Example (PDO)
Output :
mysqli_connect()
function and assign it to $conn object.$sql
.query
() function in connection object to perform database query.close()
function closes a previously created database connection.