In this tutorial you will learn about the MySQL Create Database and its application with practical example.
MySql create database:
In MySql, the create statement is used to create a database.
1 |
CREATE database [database_name]; |
Example:
1 2 3 |
<?php CREATE DATABASE emp_db; ?> |
The database names are case sensitive under Unix but this restriction does not apply in Windows. This is also true for table names.
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php $host="localhost"; //hostname $username="root"; //username $password=""; //password $con=mysql_connect("$host", "$username", "$password")or die("cannot connect"); $result = mysql_query("CREATE DATABASE emp_db"); if (!$result) echo "Database not created" . mysql_error(); else echo "Database created"; mysql_close($con); ?> |