Create a Database using MySQL Workbench

You can use the MySQL Workbench GUI to create a database. You can also create a database programmatically but here's how to do it via the GUI.

In the following example, we create a new database called "VegeShop".

  1. Click the icon for creating a new schema (you'll find this on the Workbench toolbar): Screenshot of the Create Schema icon
  2. Enter the schema name (in this case, VegeShop) and the default collation (in this case, latin1 - default collation), then click the Apply button: Screenshot of the schema creation dialog
  3. You are prompted to review the SQL statement that will be run to create the database. To run the statement (and create the database) click Apply: Creating a database 3
  4. You should see the following screen once the database has been created: Creating a database 4

The database has now been created. You will now see your new database listed under the SCHEMAS tab on the left pane:

Screenshot of SCHEMAS tab with our new database

Setting the Default Database

You can set the new database as the default database by right-clicking on it and selecting Set as Default Schema:

Screenshot of setting the default schema

You can tell when a database is the default database because its name is rendered in a bold typeface:

Screenshot of default schema (in bold)

Creating Databases Programatically

As mentioned, you can also create your databases programmatically. This is as quick and easy as writing CREATE DATABASE VegeShop. You can also add code that checks for the existence of any databases that already use that name.

Create the Tables

The above database is an empty database. It doesn't have any tables yet. As with creating your database, you can create your tables either programmatically or via the GUI.