How to use MySQL Workbench to create a database

How to use MySQL Workbench to create a database

13 mins read
Dec 21, 2020
Share
editor-page-cover
Content
Learn how to create databases with SQL
What is MySQL Workbench?
Salient features of MySQL workbench
Modeling and design
SQL develop tool
Visual performance
Database migration
Connection management
User administration
Server configuration
Exports and import
Backup, restore, and data migration
Data Export
Data Import/Restore
Migration Wizard
Tip
Model with EER diagrams, reverse/forward engineering
How to install MySQL Workbench
Keep the learning going.
How to use MySQL Workbench
Users, roles, routines, triggers, and events
Set up secure connections (local, SSH, SSL)
Local (Standard TCP/IP)
TCP/IP over SSH
SSL
Tips
Creating a database
Creating a table
Inserting data to a table
Retrieving data from a table
Visual Explain & performance tuning
Visual Explain
Profiler
Performance Dashboard
Quick wins
Troubleshooting common connection issues
Auth plugin mismatch
Port/socket problems
Bind address
SSL errors
Safe Updates mode
What to learn next
Continue learning about MySQL and databases

The MySQL Workbench from Oracle is a graphic tool for working with MySQL databases. MySQL is an open-source relational database management system, and it is the most popular database system used with PHP. It is available on Windows, Linux, and Mac OS X.

MySQL Workbench is a powerful visual tool for DBAs, database architects, and MySQL developers. This tool offers data modeling, SQL development, and administration tools for server configuration and administration.

In this tutorial, we will introduce the MySQL Workbench and show you how to get started with this powerful tool.


Learn how to create databases with SQL#

This course covers the basics of SQL. You’ll also get some hands-on practice with common SQL interview questions.

An Introductory Guide to SQL

What is MySQL Workbench?#

MySQL Workbench is a cross-platform, open-source relational database design tool that adds functionality and ease to your MySQL and SQL development. It integrates SQL design, development, creation, administration, and maintenance, also offering a graphical interface to work with your databases in a structured way.

MySQL Workbench provides capabilities for manipulating database models, such as:

  • Creating a graphical model
  • Reverse engineering for live databases to models (data modeling)
  • Forward engineering model to a script/live database
  • and more
widget

There are several relational database management systems out there, such as Microsoft SQL Server, Microsoft Access, Oracle, and DB2. The MySQL Workbench offers some advantages to consider when choosing a tool.

MySQL supports multiple storage engines each with its own specifications, unlike other tools. MySQL also offers high performance due to its design and simplicity.

It is also known for being being cost effective. The community edition is free for users, and the enterprise edition has a low licensing fee.


Salient features of MySQL workbench#

This section will go through some of MySQL Workbench’s salient features.

Modeling and design#

Modeling is a great way to visualize requirements and creating well-performing databases that can keep up with the ever-evolving data requirements. MySQL Workbench allows you to create and manipulate models, reverse engineer a live database to a model, and create and edit tables and insert data.

You can convert ER diagrams into SQL statements and push them to a SQL server. You can also create models from a target database or even imported SQL files.


SQL develop tool#

MySQL Workbench allows you to create, manage, and configure your connections and connection parameters to MySQL database servers. It also allows you to execute SQL queries on these connections using the in-built editor.

The Visual SQL Editor lets you create, edit, and run queries. It has auto-complete and color highlighters that aid in easily writing and debugging SQL statements.


Visual performance#

MySQL Workbench offers various tools that let you view and improve performance. The Performance Dashboard gives you a quick view of the different performance metrics. Performance Reports let you analyze the performance of your databases.


Database migration#

MySQL Workbench eases the process of migration. It lets you migrate from Microsoft SQL Server, SQLite, Microsoft Access, and many more. It also lets you configure, schedule, edit, and execute migration projects.


Connection management#

MySQL Workbench lets you created, manage, and organize database connections. Object management MySQL Workbench’s Object Browser allows you to visually select tables and columns. You can easily navigate between schemas, select tables and fields, create new ones, or drop them.


User administration#

MySQL Workbench makes user management a lot easier. You can easily:

  • View account information of all users on the MySQL server
  • Add and remove users
  • Grant and revoke privileges
  • Modify database permissions
  • Change passwords
  • Audit to see who did what and when

Server configuration#

MySQL Workbench lets you fine-tune MySQL servers by allowing you to view and edit advanced parameters. You can also view server logs to identify problems quicker and track database changes.You can specify a MySQL hostname to define where to host your MySQL database.


Exports and import#

MySQL Workbench allows you to easily export or import data by selecting database schemas or tables from the Object Browser.

Backup, restore, and data migration#

For production-friendly workflows, the MySQL Workbench tutorial should cover both logical dumps and GUI imports.

Data Export#

Go to Management → Data Export

  • Choose self-contained file (single .sql) or dump project folder (one file per table).
  • Select structure, data, or both.
  • Use Include Create Schema when moving to a new server.
Data Import/Restore#

Go to Management → Data Import/Restore

  • Point to a self-contained file or dump folder,
  • Map schemas, and execute.
Migration Wizard#

Go to Database → Migration Wizard to migrate from SQL Server, Access, or SQLite.
It:

  • Analyzes source objects
  • Maps data types
  • Lets you adjust mappings
  • Bulk-loads into MySQL
Tip#

For large loads, enable:

SET FOREIGN_KEY_CHECKS=0;

during import and re-enable afterwards to speed up inserts
(only if you’re sure referential integrity is preserved).

Model with EER diagrams, reverse/forward engineering#

One strength of a MySQL Workbench tutorial should be visual modeling. Workbench’s EER (Enhanced Entity-Relationship) tools help you design, document, and evolve schemas:

  • Create a model: File → New Model → Add Diagram. Drag Tables, define columns, PK/FK constraints, indexes, and relationships.

  • Reverse engineer (live DB → model): Database → Reverse Engineer to pull schema objects into a model. This is great when you inherit an existing database.

  • Forward engineer (model → DB): Database → Forward Engineer to generate SQL and apply it to a server (or save a script). Choose which objects to include and whether to drop & recreate.

  • Schema compare & synchronize: Database → Synchronize Model to diff a model against a server (or server↔server), preview changes, and apply only what’s new. This prevents drift between environments.

Best practice: Treat the model as the source of truth for schema and use forward/sync steps to keep dev/staging/prod aligned.

Enjoying the article? Scroll down to sign up for our free, bi-monthly newsletter.


How to install MySQL Workbench#

In this section, we will learn how to install MySQL Workbench. This article uses Windows, but the installation process is pretty similar for other operating systems.

  1. Visit the official Oracle site
  2. Select your operating system from the dropdown
widget
  1. Click the Go to Downloads Page button
widget
  1. Choose your installer and click Download
widget
  1. From there, you can create a new account or login to an existing one. You can skip this by clicking “No thanks, just start my download” button at the bottom.
  2. Once the installer has downloaded, open it.
  3. You may be prompted for permission, click Yes. This opens the installer. You will be asked to choose the setup type. We will go with Custom.
  4. Click Next. We will install only the MySQL server and the MySQL Workbench.
  5. Expand MySQL Servers, select the server you want to install, and pop it to the Products/Features To Be Installed window.
widget
  1. Do the same thing for Applications, and install MySQL Workbench.
widget
  1. Click Next.
  2. Click Execute to download and install the server and MySQL Workbench. This may take a while depending on your internet speed.
widget
  1. Once that’s done, click Next. We now configure our SQL server instance.
  2. Go with the default settings here and click Next.
widget
  1. Set the password for your root user. This user will have access to everything.
  2. Click Next and keep the default settings for the next steps.
widget
  1. Click Execute. Once all the configuration steps are complete, click Finish.
  2. When you reach the screen below, you are ready to launch MySQL Workbench.
widget

Keep the learning going.#

Learn MySQL and SQL without scrubbing through videos or documentation. Educative’s text-based courses are easy to skim and feature live coding environments, making learning quick and efficient.

An Introductory Guide to SQL


How to use MySQL Workbench#

In this section we will look at using MySQL Workbench. The first step will be setting up a connection, to do that, follow these steps.

  1. Open MySQL Workbench. You will see a connection under MySQL Connections. Click this connection and enter the password you set for your root user.
widget

Let’s look at this window before we move on to other things. As you can see in the image below, we have the following main sections:

widget
  • SQL editor: This is where you create and edit queries.
  • Help panel: You can view the syntax and description for a particular keyword here.
  • Navigation panel: This lets you manage your active MySQL connections and also shows the schemas on that server for a connection.
  • History output window: This displays a summary of the executed queries in the following forms: Action Output, Text Output, or History Output.

Now that your MySQL Workbench is up and running let’s get started on creating databases and retrieving data. Let’s say you own a bakery and you want to keep track of different things like how much you sell in a day or your inventory.

You can easily do that by creating a database with multiple tables, adding data to those tables, and then retrieving the relevant information.

Users, roles, routines, triggers, and events#

Workbench streamlines day-to-day administration:

  • Users and Privileges: Management → Users and Privileges to add users, assign global/object-level privileges, and roles (MySQL 8+). Use least-privilege accounts for apps.

  • Routines (stored procedures & functions): In the Navigator, expand a schema → Stored Procedures/FunctionsCreate. The routine editor provides SQL templates and validation.

  • Triggers: Expand Tables → Triggers → Create to attach BEFORE/AFTER triggers to DML operations.

  • Events: Scheduler → Events → Create to build cron-like scheduled tasks (ensure event_scheduler=ON).

  • Server Status & Logs: Management → Server Status and Server Logs help diagnose problems quickly (error log, slow query log, general log if enabled).

Set up secure connections (local, SSH, SSL)#

Beyond a simple local connection, MySQL Workbench supports secure remote access out of the box.

Local (Standard TCP/IP)#

Use hostname: localhost and port: 3306 (or your custom port).
Click Test Connection to verify credentials.

TCP/IP over SSH#

Ideal when your DB port is not exposed.
Choose Standard TCP/IP over SSH, enter:

  • SSH Hostname/Port
  • SSH Username
  • Either a password or private key file

Workbench tunnels to the DB host and then connects via the local socket/port.

SSL#

In Connection Parameters → SSL, set Use SSL to Required or Verify CA/Identity and provide the CA/client certificates.
This encrypts client↔server traffic.

Tips#

  • Use the built-in Vault to store passwords securely.
  • Click Test Connection to catch authentication or SSL issues early.
  • If you use multiple accounts, create separate saved connections per role (e.g., read-only vs admin).

Creating a database#

Let’s start with creating our database using the command: create database bakery. Execute the command using the Execute button. On successfully executing a command, you should see a green checkmark next to the action item.

widget

You can view all your databases in the Navigator panel. Follow these steps:

  1. Click Schemas at the bottom of Navigator. You can view all your databases here.
  2. If you don’t see your database here, click the Refresh button
Server instances
Server instances

Now that our database is ready, let’s add our tables.


Creating a table#

The syntax for creating a table is as follows:

create table table_name (
    column1 datatype,
    column2 datatype,
    column3 datatype,
);

For our first table Menu, we will have the following columns:

  • Item id
  • Name
  • Price
  • Date Created

The command for creating this table will be:

create table Menu (
    item_id int,
   item_name varchar,
  price int,
created_on date,
);

Execute the command, and you should see a success message in the Action Output section at the bottom. You will also see the menu table in bakery after refreshing schemas.

You can view the empty menu table by clicking the table icon next to menu, as shown below.

widget

Inserting data to a table#

Let’s add data to our table, before that let’s look at the syntax. When using insert into, you have two options:

  1. INSERT INTO table_name
  2. VALUES (value1, value2, value3, ...);

This first option is used when you enter data into every column of the table.

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

This second option is used when you want to enter data into specific columns. Since we’re adding one row, it will be:

INSERT INTO menu
VALUES (1, 'croissant', 1, '2020-12-16');

If you view your table now, you will see the data has been added.

widget

If you want to add multiple rows, use:

INSERT INTO menu
VALUES 
(2, 'bread', 3, '2020-12-16' ),
(3, 'eclairs', 2, '2020-12-16' );

Retrieving data from a table#

Let’s try retrieving data from this table. Let’s say we want to see what items we sell at our bakery. To do that, we need to display all the data in our table using:

SELECT * FROM menu;

If we want to see which item is the most expensive, we’d use:

SELECT * FROM menu
ORDER BY price DESC;

This command sorts the table based on the items with the highest price.

widget

Visual Explain & performance tuning#

To tune queries, MySQL Workbench offers multiple performance aids.

Visual Explain#

Highlight a query in the SQL Editor and click Explain (or Explain Current Statement).
Workbench renders the execution plan as a flow diagram, showing:

  • Table access
  • Join order
  • Key usage
  • Estimated costs

Look for full table scans, missing indexes, or large intermediate rows.

Profiler#

Use Session → Performance Reports or run EXPLAIN ANALYZE (in MySQL 8+) to view actual timings per plan step.

Performance Dashboard#

In Management → Performance, view server-level metrics:

  • Connections
  • InnoDB buffer pool
  • I/O

If prompted, enable Performance Schema to unlock deeper instrumentation.

Quick wins#

  • Add indexes for highly selective filters and join columns.
  • Avoid SELECT *; only fetch columns you need.
  • Check sort/group operations — ensure the ORDER BY matches existing index order where possible.

Troubleshooting common connection issues#

If you can’t connect in MySQL Workbench, check these common causes:

Auth plugin mismatch#

MySQL 8 uses caching_sha2_password by default.
Older clients need mysql_native_password or proper SSL.
In Workbench:

  • Upgrade to a recent version, or
  • Ensure SSL is configured.

Avoid downgrading authentication unless required by policy.

Port/socket problems#

Confirm port 3306 (or your custom port) is open.
On Linux/Mac, local connections may use a UNIX socket (/var/run/mysqld/mysqld.sock).

Bind address#

If the server’s my.cnf / my.ini has bind-address=127.0.0.1,
remote connections are blocked.
Use SSH tunneling or update the bind address and firewall rules.

SSL errors#

When SSL is required by the server, set Use SSL accordingly
and provide valid CA/client certificates.

Safe Updates mode#

If updates or deletes fail with warnings:

  • Disable SQL Editor → Safe Updates (which rejects UPDATE/DELETE without a key in WHERE),
  • Or add a WHERE clause with indexed columns.

What to learn next#

Congratulations on making it to the end! I hope you are now familiar with MySQL Workbench. This can be a powerful tool for building and managing your databases. But it doesn’t end here, there is so much to learn. Next, we recommend that you learn:

To get started with these concepts and more, check out Educative’s course An Introductory Guide to SQL. You’ll start by covering the basics of SQL such as how to create a database, how to insert, query, and update data. You’ll also learn fundamental concepts that data scientists use everyday such as multi-table operations, nested queries, and how to set up views.

Happy learning!


Continue learning about MySQL and databases#


Written By:
Maryam Sulemani