Skip to Content

Create A MySQL Database: Command Line & Workbench

In this tutorial, you'll learn how to create a MySQL database using the command line and MySQL WorkBench. So, whether you prefer command-line tools or graphical user interfaces, this article covers both options.

Ad - Web Hosting from SiteGround - Crafted for easy site management. Click to learn more.
Advertising Disclosure: I am compensated for purchases made through affiliate links. Click here for details.

Command Line

It only takes one command to create a MySQL database. Just make sure you've connected to your instance first, then run the following command:

mysql> CREATE DATABASE [database_name];

Just remember to replace the text [database_name] with the name of the database you'd like to create.

That's it! You can also check if your database exists first before attempting to create it by running this command instead:

mysql> CREATE DATABASE IF NOT EXISTS [database_name];

Then, to switch over to your newly created MySQL database, enter this command:

mysql> USE [database_name];

MySQL Workbench

To create a MySQL database using MySQL Workbench, you can follow these steps:

  • 1. Launch MySQL Workbench and select the instance where you want to house your new database:

MySQL Workbench home screen

  • 2. Click the "Create a new schema" icon near the top-left of the screen.

MySQL Workbench snippet

  • 3. Enter a name for your new database, then click the "Apply" button.

MySQL Workbench create schema form

  • 4. Then, it'll ask you to confirm your database creation. Click the "Apply" button here.

MySQL Workbench create schema confirm

And now your new MySQL database has been created:

MySQL Workbench schema list

Conclusion

Using the information in this article, you learned how to create a MySQL database using the command line and MySQL Workbench.

Posted by: Josh Rowe
Created: September 22, 2022

Comments

There are no comments yet. Start the conversation!

Add A Comment

Comment Etiquette: Wrap code in a <code> and </code>. Please keep comments on-topic, do not post spam, keep the conversation constructive, and be nice to each other.