</>
Skip to content
MySQL lessons (8/48)

MySQL — Create Database

Basic CREATE DATABASE

CREATE DATABASE mydb;

CREATE DATABASE IF NOT EXISTS

CREATE DATABASE IF NOT EXISTS mydb;

With Character Set

CREATE DATABASE mydb
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;

With Comment

CREATE DATABASE mydb
COMMENT 'My application database';

Examples

-- Create e-commerce database
CREATE DATABASE ecommerce
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;

-- Create blog database
CREATE DATABASE IF NOT EXISTS blog;

-- Create multiple databases
CREATE DATABASE IF NOT EXISTS shop;
CREATE DATABASE IF NOT EXISTS forum;
CREATE DATABASE IF NOT EXISTS gallery;

-- Show created databases
SHOW DATABASES;

Mini Practice

Write MySQL code that:

  1. Creates a basic database
  2. Creates a database if not exists
  3. Creates with character set
  4. Creates multiple databases

Up Next

Next: Learn about Dropping Databases.

Related Topics

Frequently Asked Questions about Create Database

What is Create Database in MySQL?

Create Database is a fundamental concept in MySQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Create Database?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Create Database.

Why is Create Database important in MySQL?

Create Database is essential for MySQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.