Languages
[Edit]
EN

MySQL - Create database

0 points
Created by:
Khloe-Kaiser
458

In this article, we would like to show you how to create database in MySQL.

Quick solution:

CREATE DATABASE `database_name`;

CREATE DATABASE example

In this example, we will create a new database - diraskDB.

Query:

CREATE DATABASE `diraskDB`;

CREATE DATABASE IF NOT EXISTS example

You can optionally add IF NOT EXISTS statement, so if the database already exists you won't get an error.

Query:

CREATE DATABASE IF NOT EXISTS `diraskDB`;

Note:

CREATE SCHEMA is a synonym for CREATE DATABASE so you can use it alternately.

Popular error

If you try to create a database that already exists with CREATE DATABASE query you will get an error:

MySQL - SQL Error: Can't create database..
MySQL - SQL Error: Can't create database..

If you try to CREATE DATABASE IF NOT EXIST you will get a warning instead:

MySQL - Note: Can't create database..
MySQL - Note: Can't create database..

Alternative titles

  1. MySQL - Create database if not exist
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Cross technology - Create database

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join