Creation or erasure of data sets in MariaDB requires advantages commonly simply given to root clients or administrators. Under these records, you have two alternatives for making a data set − the mysqladmin double and a PHP content.
mysqladmin binary
The accompanying model shows the utilization of the mysqladmin paired in making an information base with the name Products −
[root@host]# mysqladmin -u root -p create PRODUCTS
Enter password:******
PHP Create Database Script
PHP utilizes the mysql_query work in making a MariaDB information base. The capacity utilizes two boundaries, one discretionary, and returns either an estimation of "valid" when effective, or "bogus" when not.
Syntax
Audit the accompanying make information base content language structure −
bool mysql_query( sql, connection );
The depiction of the boundaries is given beneath −
- sql
- This required parameter consists of the SQL query needed to perform the operation.
- connection
- When not specified, this optional parameter uses the most recent connection used.
Attempt the accompanying model code for making an information base −
<html>
<head>
<title>Create a MariaDB Database</title>
</head>
<body>
<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully<br />';
$sql = 'CREATE DATABASE PRODUCTS';
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not create database: ' . mysql_error());
}
echo "Database PRODUCTS created successfully\n";
mysql_close($conn);
?>
</body>
</html>
On fruitful erasure, you will see the accompanying yield −
mysql> Database PRODUCTS created successfully
mysql> SHOW DATABASES;
+-----------------------+
| Database |
+-----------------------+
| PRODUCTS |
+-----------------------+