Create Database using MySqladmin

You can create any database using MySQL mysqladmin binary. Either it is a local server made by using Xampp or Online servers. This way you can have a database ready.

Example:

A simple example to Show you as how to  create database named as “Database tutorials”:

[root@host]# mysqladmin -u root -p create Database tutorials

Enter password:*****

The above-given code will create a MySQL database  “Database Tutorials”.

 

Create Database using PHP Script:

PHP uses the mysql_query function in order create or delete a MySQL database.

Syntax:

bool mysql_query( SQL, connection );

CommandsDetails
sqlRequired – SQL query in order to create or delete a MySQL database
connection“Optional” – if it is not specified, then last opened connection which a user used by mysql_connect will be used in the current one.

 

Example:

Creating a database:

 
[php]





‘;
$mysql = ‘CREATE YOUR OWN DATABASE TUTORIALS’;
$Result = mysql_query( $sql, $con );
if(! $result )
{
die(‘Could not create database due to error: ‘ . mysql_error());
}
echo “Database TUTORIALS created successfully without any error\n”;
mysql_close($conn);
?>

[/php]

Related Article

Leave a Comment