What would seem like a complex task — creating a new database — is possibly the simplest statement of all!

Syntax

The syntax is extremely simple:

CREATE DATABASE `databasename`;

Naming conventions for databases vary. Stick to a short, simple, descriptive name consisting of lowercase letters only and you can’t go wrong.

Example

We will use MySQL Workbench to create our new database with the following statement:

CREATE DATABASE `dbtest`;

Creating a database in MySQL Workbench.Creating a database in MySQL Workbench.
  1. Select the Query window
  2. Type the following SQL statement: CREATE DATABASE dbtest;
  3. Click the Execute button
  4. The result displayed in the Output panel
  5. Click the Refresh button
  6. The new database, dbtest, appears in the Navigator panel

Next step

To add a user with some privileges to your new database, see the CREATE USER & GRANT PRIVILEGES in MySQL tutorial.


References:

  1. W3schools. (2023). SQL CREATE DATABASE Statement. Available at: https://www.w3schools.com/sql/sql_create_db.asp (Accessed: 25 February 2023).

By MisterFoxOnline

Mister Fox AKA @MisterFoxOnline is an ICT, IT and CAT Teacher who has just finished training as a Young Engineers instructor. He has a passion for technology and loves to find solutions to problems using the skills he has learned in the course of his IT career.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.