How to create a Database in MySQL

What is a Database ?

Database is a collection of tables that belong to or used by an application. Different users in an use case of application might access the tables of a database. Multiple databases could be hosted in a single MySQL server, because of which a client has to select a database prior to requesting the SQL operations.

We shall learn how to create a database and in the subsequent tutorials, we shall create tables in the database.

Syntax to Create a  DATABASE in MySQL

Following is the syntax to create a database. Providing database name is mandatory.

CREATE DATABASE <database_name>;

An example to Create a DATABASE in MySQL

Following is example SQL query to create a database named students

CREATE DATABASE students;
When the above SQL Query is executed, a database named “students” is created.

To check if the database “students” is created or not , run the following SQL Query

SHOW DATABASES;

“students” database has been successfully created. Other databases that appear in the list are default databases that come with MySQL Server.

Create a Database in MySQL - MySQL Tutorial - www.tutorialkart.com

Create a Database in MySQL

Note : If you have come across SCHEMA in other database management systems, SCHEMA is a collection of tables and DATABASE is a collection of SCHEMAs. But in MySQL, there is nothing specifically a SCHEMA. Hence SCHEMA could be used as an alias to DATABASE.