Creating a database using MySQL Workbench with a SQL script is relatively straightforward. Simply go through the following steps:
- Open MySQL Workbench.
- Connect to your local instance or a dev/test instance. Don't perform any of these steps on a live production server.
- Click the new SQL script button, which is highlighted in the following screenshot:
- Copy or type the following script into the script window in MySQL Workbench:
CREATE DATABASE yourschema;
- Click the execute script button, highlighted in the following screenshot:
- Once the script is done executing, the Output panel will show that it is successful:
You don't need the backticks (`) around yourschema in the preceding script, but MySQL puts them there by default whenever you script an object. We will walk through how to script objects later in this chapter.
- Once you click the refresh button on your SCHEMAS panel, you will see your new database, as shown in the following screenshot:
Now, you will be able to add database objects, such as tables, to your new database. We will do a walkthrough of this in the Creating a table in the database table section later in this chapter.