This guide walks you through creating a new MySQL database using MySQL Workbench, the official graphical tool for MySQL. You’ll learn how to connect to a server, create a schema (which is what MySQL calls a database), and verify that it’s ready for tables and data. No prior experience with Workbench is needed, but you should have MySQL Workbench installed and access to a running MySQL server.
What You’ll Need
- MySQL Workbench installed (free from the official MySQL website).
- A running MySQL server instance (local or remote) with credentials (host, port, username, password).
- Permission to create databases on that server (typically the root user or a user with CREATE privileges).
Step-by-Step
- Launch MySQL Workbench. On Windows, use the Start menu; on macOS, open it from Applications. The home screen shows a list of saved connections and a “MySQL Connections” panel.
- Connect to your MySQL server. Click the connection tile (e.g., “Local instance MySQL80”) or click the + icon to set up a new connection. Enter the hostname (usually
localhostor 127.0.0.1), port (default 3306), and your username. Click “Store in Vault” to save the password, then click “OK” and double-click the connection to open it. - Wait for the connection to establish. The main Workbench window opens with a query editor, a navigator panel on the left, and a toolbar. You should see a green indicator if connected successfully.
- Locate the “Schemas” tab. In the left navigator panel, click the “Schemas” tab (it looks like a database cylinder). This shows all existing databases on the server.
- Click the “Create a New Schema” icon. It’s the small database icon with a plus sign, located in the toolbar just above the Schemas list. This opens the “Create Schema” dialog.
- Enter a name for your database. In the “Name” field, type a descriptive name (e.g.,
my_app_db). Use lowercase letters, numbers, and underscores; avoid spaces and special characters. MySQL database names are case-sensitive on some systems, so be consistent. - Set the default collation (optional). Click the “Collation” dropdown. The default is usually
utf8mb4_0900_ai_ci(or similar). If you’re unsure, leave it as is—it supports most modern applications. You can change it later. - Click “Apply”. A dialog shows the SQL script that will run, something like
CREATE SCHEMA `my_app_db`;. Review it, then click “Apply” again. - Click “Finish”. The script executes, and Workbench confirms the schema was created. Click “Finish” to close the dialog.
- Verify the new database. Back in the Schemas panel, right-click the Schemas area and select “Refresh All”. Your new database appears in the list. Click the arrow next to it to expand and see that it’s empty (no tables yet).
- Set it as default (optional). To run queries against this database without prefixing table names, double-click the database name in the Schemas panel. It will appear bold, indicating it’s the default schema.
Common Mistakes
- Forgetting to refresh: After creating a schema, it may not appear immediately. Always right-click and choose “Refresh All” in the Schemas panel.
- Using spaces or hyphens in the name: MySQL allows them only if you quote the name with backticks, but it causes headaches. Stick to underscores.
- Choosing the wrong collation: If you pick an old collation like
latin1_swedish_ci, you may have trouble storing emoji or accented characters. Stick with utf8mb4 unless you know why you need something else. - Not having CREATE privilege: If you’re not using an admin account, you’ll get an “Access denied” error. Ask your DBA for a user with CREATE permission.
- Clicking “Apply” too fast: The review step shows the SQL; it’s a good habit to read it, especially if you’re learning.
Tips
- Use a naming convention: prefix with the project name (e.g.,
blog_prod,blog_dev) to keep environments separate. - If you plan to use an ORM (like Django or Rails), they often create the database for you—but if you create it manually, ensure the charset matches what the ORM expects.
- You can also create a database via the SQL tab: type
CREATE DATABASE my_db;and execute it. The GUI method is just a wrapper around this. - Take note of the server’s character set. You can check it with
SHOW VARIABLES LIKE 'character_set_server';to understand the default.
Troubleshooting
- Connection fails with “Can’t connect to MySQL server”: Verify the server is running (e.g.,
sudo systemctl status mysqlon Linux, or check services on Windows). Check the port—if you changed it, update the connection. If connecting remotely, ensure the server’s firewall allows port 3306 and that MySQL is configured to listen on the network (bind-address). - “Access denied for user ‘x’@’localhost'”: The username or password is wrong, or the user lacks privileges. Try connecting with root or contact your administrator.
- “CREATE SCHEMA command denied”: Your user doesn’t have the CREATE privilege. Ask your DBA to grant it:
GRANT CREATE ON *.* TO 'user'@'host'; - Database not visible after creation: Click the “Refresh All” icon in the Schemas panel. If still missing, run
SHOW DATABASES;in the query editor to see if it exists on the server. - Workbench freezes or crashes: Update to the latest version. Also try disconnecting and reconnecting. Sometimes a corrupted workspace file causes issues; reset the layout via “View” > “Reset to Default Layout”.
Frequently Asked Questions
What is the difference between a schema and a database in MySQL?
In MySQL, they are the same thing. The terms are used interchangeably. CREATE SCHEMA is a synonym for CREATE DATABASE.
Can I create a database from the command line instead of Workbench?
Yes. Use mysql -u root -p to enter the MySQL shell, then run CREATE DATABASE my_db;. Workbench is just a visual tool that sends the same command.
What collation should I choose?
For most modern applications, use utf8mb4_unicode_ci or utf8mb4_0900_ai_ci. They support all Unicode characters, including emoji. If you’re unsure, leave the default.
How do I delete a database in Workbench?
Right-click the database in the Schemas panel and select “Drop Schema”. Confirm the action. Be careful—this permanently deletes all tables and data.
Can I create multiple databases in one session?
Yes, repeat the steps as many times as you need. Each schema is independent.
Why is my database name shown in lowercase even though I typed uppercase?
MySQL on some systems (like Windows) stores database names in lowercase unless you set lower_case_table_names to 0. It’s best to use lowercase from the start to avoid confusion.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Aion2 Banned Account: What to Do
- Turn Company Strategy into Team Priorities
- Why Game Servers Need DDoS Protection
- Embedded Finance for Small Businesses: How It Works
- Best 3D Printer Brands for Budget, Workflow & Detail
- Brother Printer Keeps Going Offline? Fix It Fast