MySQL - Create Database

You have the root user access to create database in mysql. The CREATE DATABASE statement is used to create a new MYSQL database.

You can create new database using below query.

MYSQL Syntax :
CREATE DATABASE databasename;
SHOW DATABASES;
USE databasename;


MYSQL Query :
CREATE DATABASE ARYATECHNO

Shell command script:
Also you can run below mysql command in shell
[root@host]# mysql -u root -p
Enter password:********
mysql> CREATE DATABASE ARYATECHNO;


PHP SCRIPT :
You can create database using php code as per as below.
$connection= mysql_connect($hostname, $username, $password);
$returnval = mysql_query("CREATE DATABASE ARYATECHNO", $connection);
mysql_close($connection);

You have admin privilege before creating any database.

Other MYSQL Command for database

  • You can check list of database in mysql using sql command SHOW DATABASES; statement.
  • Also You can select database using sql command USE databasename; statement.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

64511