To create a new database using MySQL Workbench, follow these steps:
Steps to Create a Database in MySQL Workbench:
- Open MySQL Workbench:
- Launch MySQL Workbench on your computer and connect to your MySQL server instance by double-clicking on the connection.
- Access the Schema Tab:
- Once connected, navigate to the Navigator panel on the left-hand side. Look for the Schemas section where existing databases are listed.
- Create a New Schema (Database):
- Click the + icon next to the “Schemas” heading or right-click in the “Schemas” section and select “Create Schema”.
- Define the Schema Name:
- In the “Schema Name” field, type the name for your new database (e.g.,
new_database
). - Ensure the name follows database naming conventions (e.g., no spaces, special characters, or reserved words).
- In the “Schema Name” field, type the name for your new database (e.g.,
- Set Default Collation (Optional):
- Under “Default Collation,” you can select a collation for the database (default is usually
utf8mb4_general_ci
). - The collation determines the character set and sorting rules for text in the database.
- Under “Default Collation,” you can select a collation for the database (default is usually
- Apply Changes:
- Click the Apply button. A script will be generated to create the database.
- Review the SQL statement:
CREATE SCHEMA `new_database` DEFAULT CHARACTER SET utf8mb4;
- Click Apply to execute the statement.
- Confirm Creation:
- Once the operation is successful, click Finish. Your new database will now appear in the “Schemas” list in the Navigator.
- Set as Default Schema (Optional):
- If you plan to work with this database immediately, right-click on the database name in the “Schemas” section and select “Set as Default Schema”.
Notes:
- If you prefer, you can use the SQL Editor within MySQL Workbench to create the database by executing the following SQL command:
CREATE DATABASE new_database;
- After creating the database, you can create tables and other objects by selecting the database and using the table design tool.
By following these steps, you can easily create and configure a new database in MySQL Workbench.